[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <172327563820.395581.15278397593129937648.kvalo@kernel.org>
Date: Sat, 10 Aug 2024 07:40:39 +0000 (UTC)
From: Kalle Valo <kvalo@...nel.org>
To: "Gustavo A. R. Silva" <gustavoars@...nel.org>
Cc: Stanislav Yakovlev <stas.yakovlev@...il.com>,
linux-wireless@...r.kernel.org, linux-kernel@...r.kernel.org,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
linux-hardening@...r.kernel.org
Subject: Re: [next] wifi: ipw2x00: libipw: Avoid
-Wflex-array-member-not-at-end warnings
"Gustavo A. R. Silva" <gustavoars@...nel.org> wrote:
> -Wflex-array-member-not-at-end was introduced in GCC-14, and we are
> getting ready to enable it, globally.
>
> So, in order to avoid ending up with a flexible-array member in the
> middle of multiple other structs, we use the `__struct_group()`
> helper to create a new tagged `struct libipw_hdr_3addr_hdr`.
> This structure groups together all the members of the flexible
> `struct libipw_hdr_3addr` except the flexible array.
>
> As a result, the array is effectively separated from the rest of the
> members without modifying the memory layout of the flexible structure.
> We then change the type of the middle struct members currently causing
> trouble from `struct libipw_hdr_3addr` to `struct libipw_hdr_3addr_hdr`.
>
> We also want to ensure that when new members need to be added to the
> flexible structure, they are always included within the newly created
> tagged struct. For this, we use `static_assert()`. This ensures that the
> memory layout for both the flexible structure and the new tagged struct
> is the same after any changes.
>
> This approach avoids having to implement `struct libipw_hdr_3addr_hdr`
> as a completely separate structure, thus preventing having to maintain
> two independent but basically identical structures, closing the door
> to potential bugs in the future.
>
> Also, remove a couple of unused structures `struct libipw_ibss_dfs` and
> `struct libipw_assoc_request`.
>
> So, with these changes, fix the following warnings:
>
> drivers/net/wireless/intel/ipw2x00/libipw.h:403:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> drivers/net/wireless/intel/ipw2x00/libipw.h:420:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> drivers/net/wireless/intel/ipw2x00/libipw.h:433:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> drivers/net/wireless/intel/ipw2x00/libipw.h:441:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> drivers/net/wireless/intel/ipw2x00/libipw.h:447:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> drivers/net/wireless/intel/ipw2x00/libipw.h:460:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> drivers/net/wireless/intel/ipw2x00/libipw.h:468:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> drivers/net/wireless/intel/ipw2x00/libipw.h:476:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> drivers/net/wireless/intel/ipw2x00/libipw.h:592:36: 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@...nel.org>
Patch applied to wireless-next.git, thanks.
089332e703b6 wifi: ipw2x00: libipw: Avoid -Wflex-array-member-not-at-end warnings
--
https://patchwork.kernel.org/project/linux-wireless/patch/ZrJqtUpCI+uCeb4D@cute/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Powered by blists - more mailing lists