On Mon, Jan 10, 2022 at 03:11:18PM -0800, Nick Desaulniers wrote: > On Mon, Jan 10, 2022 at 2:48 PM Sakari Ailus > <sakari.ailus@xxxxxxxxxxxxxxx> wrote: > > > > Pointers V4L2 pixelformat and dataformat fields in a few packed structs > > are directly passed to printk family of functions. > > I would rephrase the below statement... > > > This could result in an > > unaligned access albeit no such possibility appears to exist at the > > moment i.e. this clang warning appears to be a false positive. > > ...to: > > warning: taking address of packed member 'pixelformat' of class or > structure 'v4l2_pix_format_mplane' may result in an unaligned pointer > value [-Waddress-of-packed-member] > > The warning is correct; Exactly. I'm going to repeat that in the comment to my patch. > because `struct v4l2_pix_format_mplane` is > __packed, it's members also have __aligned(1). Taking the address of > such members results in the use of underaligned pointers which is UB > and may be caught by UBSAN or fault on architectures without unaligned > loads should the struct instance happen to be allocated without any > natural alignment. -- With Best Regards, Andy Shevchenko