Re: [PATCH v2][next] w1: Avoid -Wflex-array-member-not-at-end warnings

From: Gustavo A. R. Silva
Date: Mon Apr 07 2025 - 19:12:03 EST




On 07/04/25 14:26, Kees Cook wrote:
On Mon, Apr 07, 2025 at 01:36:26PM -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.

So, with these changes, fix the following warnings:

drivers/w1/w1_netlink.c:198:31: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/w1/w1_netlink.c:219:31: 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>
---
Changes in v2:
- Fix memcpy() instance - use new pointer `pkg_msg`, instead of `packet`. (Kees)

Thanks! You didn't want to use object assignments? Those are type
checked. :)

Mmh... you're so persuasive :p - OK, I'll respin!


Reviewed-by: Kees Cook <kees@xxxxxxxxxx>


Thanks!
--
Gustavo