]> www.infradead.org Git - users/jedix/linux-maple.git/commit
wifi: mwl8k: Avoid -Wflex-array-member-not-at-end warnings
authorGustavo A. R. Silva <gustavoars@kernel.org>
Mon, 25 Mar 2024 03:12:05 +0000 (21:12 -0600)
committerKalle Valo <kvalo@kernel.org>
Thu, 28 Mar 2024 13:08:06 +0000 (15:08 +0200)
commit5c4250092fadde9e11ac87a82b8fa4e2a5a0c767
treef3f567d7bcd2179706acf589275240a84fbe1cf8
parentf4b09b29f8b498e6c5f7cd582b5c0cbd37c1b90a
wifi: mwl8k: Avoid -Wflex-array-member-not-at-end warnings

-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
Link: https://github.com/KSPP/linux/issues/202
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/ZgDrhe5pbV/WvDiZ@neat
drivers/net/wireless/marvell/mwl8k.c