wifi: iwlwifi: mld: rx: Avoid a -Wflex-array-member-not-at-end warning
PATCH 1/1 wifi: iwlwifi: mld: rx: Avoid a -Wflex-array-member-not-at-end warning
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are getting ready to enable it, globally.
Use an anonymous embedded struct (enabled via -fms-extensions) to split the header portion from the flexible-array member in struct iwl_rxq_sync_cmd, so the new header type struct iwl_rxq_sync_cmd_hdr can be referenced independently (of the flexible-array member), and fix the following warning:
drivers/net/wireless/intel/iwlwifi/mld/rx.c:2172:41: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
Add comments and a static_assert() to prevent adding new members directly to struct iwl_rxq_sync_cmd. Any new members must be added to struct iwl_rxq_sync_cmd_hdr instead. This preserves the expected memory layout between the header and the flexible-array member.
--- .../net/wireless/intel/iwlwifi/fw/api/rx.h | 21 ++++++++++++++++--- drivers/net/wireless/intel/iwlwifi/mld/rx.c | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/api/rx.h +18 -3
@@ -918,19 +918,34 @@ struct iwl_rss_config_cmd {#define IWL_MULTI_QUEUE_SYNC_SENDER_MSK 0xf/** -* struct iwl_rxq_sync_cmd - RXQ notification trigger +* struct iwl_rxq_sync_cmd_hdr - RXQ notification trigger header * * @flags: flags of the notification. bit 0:3 are the sender queue * @rxq_mask: rx queues to send the notification on * @count: number of bytes in payload, should be DWORD aligned -* @payload: data to send to rx queues */ -struct iwl_rxq_sync_cmd { +struct iwl_rxq_sync_cmd_hdr {__le32 flags;__le32 rxq_mask;__le32 count; +} __packed; + +/** +* struct iwl_rxq_sync_cmd - RXQ notification trigger +* +* (NOTE: New members MUST NOT be added directly to this struct. Add them to +* struct iwl_rxq_sync_cmd_hdr instead.) +* +* @iwl_rxq_sync_cmd_hdr: anonymous embedded header - members are directly +* accessible +* @payload: data to send to rx queues +*/ +struct iwl_rxq_sync_cmd { +struct iwl_rxq_sync_cmd_hdr ;u8 payload[]; } __packed;/* MULTI_QUEUE_DRV_SYNC_HDR_CMD_API_S_VER_1 */ +static_assert (offsetof(struct iwl_rxq_sync_cmd , payload) ==sizeof (struct iwl_rxq_sync_cmd_hdr ), +"New members must be added to struct iwl_rxq_sync_cmd_hdr instead." );/** * struct iwl_rxq_sync_notification - Notification triggered by RXQ
drivers/net/wireless/intel/iwlwifi/mld/rx.c +1 -1
@@ -2172,7 +2172,7 @@ void iwl_mld_sync_rx_queues(struct iwl_mld *mld, {u8 num_rx_queues = mld->trans->info.num_rxqs;struct { -struct iwl_rxq_sync_cmd sync_cmd; +struct iwl_rxq_sync_cmd_hdr sync_cmd;struct iwl_mld_internal_rxq_notif notif; } __packed cmd = { .sync_cmd.rxq_mask =cpu_to_le32 (BIT (num_rx_queues) -1 ),
Signature · 1 line
2.43.0