On Mon, 01 Feb 2021, Arnd Bergmann wrote:

> From: Arnd Bergmann <a...@arndb.de>
> 
> Building with 'make W=1' enables -Wpacked-not-aligned, and this
> warns about pmcraid because of incompatible alignment constraints for
> pmcraid_passthrough_ioctl_buffer:
> 
> drivers/scsi/pmcraid.h:1044:1: warning: alignment 1 of 'struct 
> pmcraid_passthrough_ioctl_buffer' is less than 32 [-Wpacked-not-aligned]
>  1044 | } __attribute__ ((packed));
>       | ^
> drivers/scsi/pmcraid.h:1041:24: warning: 'ioarcb' offset 16 in 'struct 
> pmcraid_passthrough_ioctl_buffer' isn't aligned to 32 [-Wpacked-not-aligned]
>  1041 |  struct pmcraid_ioarcb ioarcb;
> 
> The inner structure is documented as having 32 byte alignment here,
> but is starts at a 16 byte offset in the outer structure, so it's never
> actually aligned, as the outer structure is also marked 'packed'.
> 
> Lee Jones point this out as one of the last files that need to be changed
> before the warning can be enabled by default.
> 
> Change the annotations in a way that avoids the warning but leaves the
> layout unchanged, by removing the packing on the inner structure and
> adding it to the outer one. The one-byte request_buffer[] array should
> have been a flexible array member here, which is how I change it to
> avoid extra padding from the alignment attribute.

Looks good to me.

Reviewed-by: Lee Jones <lee.jo...@linaro.org>

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

Reply via email to