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

Gustavo A. R. Silva
2025-04-07T23:11:52Z

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@kernel.org>
>> ---
>> 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@kernel.org>
>

Thanks!
--
Gustavo