[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <171163129374.129280.17590412225670656069.kvalo@kernel.org>
Date: Thu, 28 Mar 2024 13:08:15 +0000 (UTC)
From: Kalle Valo <kvalo@...nel.org>
To: "Gustavo A. R. Silva" <gustavoars@...nel.org>
Cc: linux-wireless@...r.kernel.org, linux-kernel@...r.kernel.org,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
linux-hardening@...r.kernel.org
Subject: Re: [PATCH][next] wifi: mwl8k: Avoid -Wflex-array-member-not-at-end
warnings
"Gustavo A. R. Silva" <gustavoars@...nel.org> wrote:
> -Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
> ready to enable it globally.
>
> There is currently an object (`header`), at the beginning of multiple
> structures, that contains a flexible structure (`struct mwl8k_cmd_pkt`),
> for example:
>
> struct mwl8k_cmd_get_hw_spec_sta {
> struct mwl8k_cmd_pkt header;
>
> ...
>
> __le32 num_tx_desc_per_queue;
> __le32 total_rxd;
> } __packed;
>
> So, in order to avoid ending up with flexible-array members in the
> middle of multiple other structs, we use the `__struct_group()` helper
> to separate the flexible array from the rest of the members in the
> flexible structure:
>
> struct mwl8k_cmd_pkt {
> __struct_group(mwl8k_cmd_pkt_hdr, hdr, __packed,
>
> ... the rest of the members
>
> );
> char payload[];
> } __packed;
>
> With the change described above, we now declare objects of the type of
> the tagged struct, in this case `struct mwl8k_cmd_pkt_hdr`, without
> embedding flexible arrays in the middle of another struct:
>
> struct mwl8k_cmd_get_hw_spec_sta {
> struct mwl8k_cmd_pkt_hdr header;
>
> ...
>
> __le32 num_tx_desc_per_queue;
> __le32 total_rxd;
> } __packed;
>
> Also, update the type of a couple of variables and function parameters
> from `struct mwl8k_cmd_pkt` to `struct mwl8k_cmd_pkt_hdr`.
>
> So, with these changes, fix 33 of the following warnings[1]:
> drivers/net/wireless/marvell/mwl8k.c:2353:30: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
>
> Link: https://gist.github.com/GustavoARSilva/7a841a92c0f24e5efdb30ce02b601eb8 [1]
> Link: https://github.com/KSPP/linux/issues/202
> Signed-off-by: Gustavo A. R. Silva <gustavoars@...nel.org>
Patch applied to wireless-next.git, thanks.
5c4250092fad wifi: mwl8k: Avoid -Wflex-array-member-not-at-end warnings
--
https://patchwork.kernel.org/project/linux-wireless/patch/ZgDrhe5pbV/WvDiZ@neat/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Powered by blists - more mailing lists