mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kalle Valo <kvalo@kernel.org>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] wifi: mwl8k: Avoid -Wflex-array-member-not-at-end warnings
Date: Thu, 28 Mar 2024 13:08:15 +0000 (UTC)	[thread overview]
Message-ID: <171163129374.129280.17590412225670656069.kvalo@kernel.org> (raw)
In-Reply-To: <ZgDrhe5pbV/WvDiZ@neat>

"Gustavo A. R. Silva" <gustavoars@kernel.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@kernel.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


      reply	other threads:[~2024-03-28 13:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25  3:12 Gustavo A. R. Silva
2024-03-28 13:08 ` Kalle Valo [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=171163129374.129280.17590412225670656069.kvalo@kernel.org \
    --to=kvalo@kernel.org \
    --cc=gustavoars@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®