Re: [PATCH][next] nfp: tls: Avoid -Wflex-array-member-not-at-end warnings

From: Simon Horman
Date: Mon Nov 24 2025 - 09:14:02 EST


On Thu, Nov 20, 2025 at 11:39:39AM +0900, 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.
>
> So, in order to avoid ending up with flexible-array members in the
> middle of other structs, we use the `struct_group_tagged()` helper
> to separate the flexible array from the rest of the members in the
> flexible structure. We then use the newly created tagged `struct
> nfp_crypto_req_add_front_hdr` to replace the type of the objects
> causing trouble in a couple of structures.
>
> We also want to ensure that when new members need to be added to the
> flexible structure, they are always included within the newly created
> tagged struct. For this, we use `static_assert()`. This ensures that the
> memory layout for both the flexible structure and the new tagged struct
> is the same after any changes.
>
> Lastly, use container_of() to retrieve a pointer to the flexible
> structure and, through that, access the flexible-array member when
> needed.
>
> So, with these changes, fix the following warnings:
>
> drivers/net/ethernet/netronome/nfp/nfdk/../crypto/fw.h:65:41: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> drivers/net/ethernet/netronome/nfp/nfdk/../crypto/fw.h:58:41: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> drivers/net/ethernet/netronome/nfp/nfd3/../crypto/fw.h:58:41: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> drivers/net/ethernet/netronome/nfp/nfd3/../crypto/fw.h:65:41: 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>

Reviewed-by: Simon Horman <horms@xxxxxxxxxx>