-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.

Signed-off-by: Gustavo A. R. Silva <[email protected]>
---
 .../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(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h 
b/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h
index ac6c1ef2cbcd..02a5bacfb175 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h
@@ -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
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/rx.c 
b/drivers/net/wireless/intel/iwlwifi/mld/rx.c
index a2e586c6ea67..492c03b8e5a0 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/rx.c
@@ -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),
-- 
2.43.0


Reply via email to