mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-20 06:20:41 +00:00

-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 ieee80211_radiotap_header_fixed`. This structure groups together all the members of the flexible `struct ieee80211_radiotap_header` 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 ieee80211_radiotap_header` to `struct ieee80211_radiotap_header_fixed`. We also want to ensure that in case 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 ieee80211_radiotap_header_fixed` 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. So, with these changes, fix the following warnings: drivers/net/wireless/ath/wil6210/txrx.c:309:50: 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/ipw2100.c:2521:50: 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/ipw2200.h:1146:42: 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:595:36: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/net/wireless/marvell/libertas/radiotap.h:34:42: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/net/wireless/marvell/libertas/radiotap.h:5:42: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/net/wireless/microchip/wilc1000/mon.c:10:42: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/net/wireless/microchip/wilc1000/mon.c:15:42: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/net/wireless/virtual/mac80211_hwsim.c:758:42: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/net/wireless/virtual/mac80211_hwsim.c:767:42: 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@kernel.org> Link: https://patch.msgid.link/ZwBMtBZKcrzwU7l4@kspp Signed-off-by: Johannes Berg <johannes.berg@intel.com>
45 lines
1.2 KiB
C
45 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#include <net/ieee80211_radiotap.h>
|
|
|
|
struct tx_radiotap_hdr {
|
|
struct ieee80211_radiotap_header_fixed hdr;
|
|
u8 rate;
|
|
u8 txpower;
|
|
u8 rts_retries;
|
|
u8 data_retries;
|
|
} __packed;
|
|
|
|
#define TX_RADIOTAP_PRESENT ( \
|
|
(1 << IEEE80211_RADIOTAP_RATE) | \
|
|
(1 << IEEE80211_RADIOTAP_DBM_TX_POWER) | \
|
|
(1 << IEEE80211_RADIOTAP_RTS_RETRIES) | \
|
|
(1 << IEEE80211_RADIOTAP_DATA_RETRIES) | \
|
|
0)
|
|
|
|
#define IEEE80211_FC_VERSION_MASK 0x0003
|
|
#define IEEE80211_FC_TYPE_MASK 0x000c
|
|
#define IEEE80211_FC_TYPE_MGT 0x0000
|
|
#define IEEE80211_FC_TYPE_CTL 0x0004
|
|
#define IEEE80211_FC_TYPE_DATA 0x0008
|
|
#define IEEE80211_FC_SUBTYPE_MASK 0x00f0
|
|
#define IEEE80211_FC_TOFROMDS_MASK 0x0300
|
|
#define IEEE80211_FC_TODS_MASK 0x0100
|
|
#define IEEE80211_FC_FROMDS_MASK 0x0200
|
|
#define IEEE80211_FC_NODS 0x0000
|
|
#define IEEE80211_FC_TODS 0x0100
|
|
#define IEEE80211_FC_FROMDS 0x0200
|
|
#define IEEE80211_FC_DSTODS 0x0300
|
|
|
|
struct rx_radiotap_hdr {
|
|
struct ieee80211_radiotap_header_fixed hdr;
|
|
u8 flags;
|
|
u8 rate;
|
|
u8 antsignal;
|
|
} __packed;
|
|
|
|
#define RX_RADIOTAP_PRESENT ( \
|
|
(1 << IEEE80211_RADIOTAP_FLAGS) | \
|
|
(1 << IEEE80211_RADIOTAP_RATE) | \
|
|
(1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) |\
|
|
0)
|
|
|