Re: [PATCH][next] scsi: sd: Avoid -Wflex-array-member-not-at-end warning
From: Kees Cook
Date: Wed Apr 30 2025 - 17:33:51 EST
On Fri, Apr 25, 2025 at 06:28:35PM -0600, Gustavo A. R. Silva wrote:
> -Wflex-array-member-not-at-end was introduced in GCC-14, and we are
> getting ready to enable it, globally.
>
> Use the `DEFINE_RAW_FLEX()` helper for on-stack definitions of
> a flexible structure where the size of the flexible-array member
> is known at compile-time, and refactor the rest of the code,
> accordingly.
>
> Also, there is no need to use the DECLARE_FLEX_ARRAY() helper.
> Replace it with a regular flexible-array member declaration
> instead.
>
> So, with these changes, fix the following warning:
>
> drivers/scsi/sd.c:3195:50: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
>
> Signed-off-by: Gustavo A. R. Silva <gustavoars@xxxxxxxxxx>
Looks good; thanks!
Reviewed-by: Kees Cook <kees@xxxxxxxxxx>
--
Kees Cook