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