[PATCH 02/15] iwlwifi: mvm: fix gcc-10 zero-length-bounds warning

From: Arnd Bergmann
Date: Thu Apr 30 2020 - 17:32:06 EST


gcc-10 complains when a zero-length array is accessed:

drivers/net/wireless/intel/iwlwifi/mvm/tx.c: In function 'iwl_mvm_rx_ba_notif':
drivers/net/wireless/intel/iwlwifi/mvm/tx.c:1929:17: warning: array subscript 9 is outside the bounds of an interior zero-length array 'struct iwl_mvm_compressed_ba_tfd[0]' [-Wzero-length-bounds]
1929 | &ba_res->tfd[i];
| ~~~~~~~~~~~^~~
In file included from drivers/net/wireless/intel/iwlwifi/mvm/../fw/api/tdls.h:68,
from drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h:68,
from drivers/net/wireless/intel/iwlwifi/mvm/sta.h:73,
from drivers/net/wireless/intel/iwlwifi/mvm/mvm.h:83,
from drivers/net/wireless/intel/iwlwifi/mvm/tx.c:72:
drivers/net/wireless/intel/iwlwifi/mvm/../fw/api/tx.h:769:35: note: while referencing 'tfd'
769 | struct iwl_mvm_compressed_ba_tfd tfd[0];
| ^~~

Change this structure to use a flexible-array member for 'tfd' instead,
along with the various structures using an zero-length ieee80211_hdr
array that do not show warnings today but might be affected by similar
issues in the future.

Fixes: 6f68cc367ab6 ("iwlwifi: api: annotate compressed BA notif array sizes")
Fixes: c46e7724bfe9 ("iwlwifi: mvm: support new BA notification response")
Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
---
drivers/net/wireless/intel/iwlwifi/fw/api/tx.h | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/tx.h b/drivers/net/wireless/intel/iwlwifi/fw/api/tx.h
index f1d1fe96fecc..82d59b5a5f8c 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/tx.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/tx.h
@@ -293,7 +293,7 @@ struct iwl_tx_cmd {
__le16 pm_frame_timeout;
__le16 reserved4;
u8 payload[0];
- struct ieee80211_hdr hdr[0];
+ struct ieee80211_hdr hdr[];
} __packed; /* TX_CMD_API_S_VER_6 */

struct iwl_dram_sec_info {
@@ -319,7 +319,7 @@ struct iwl_tx_cmd_gen2 {
__le32 flags;
struct iwl_dram_sec_info dram_info;
__le32 rate_n_flags;
- struct ieee80211_hdr hdr[0];
+ struct ieee80211_hdr hdr[];
} __packed; /* TX_CMD_API_S_VER_7 */

/**
@@ -342,7 +342,7 @@ struct iwl_tx_cmd_gen3 {
struct iwl_dram_sec_info dram_info;
__le32 rate_n_flags;
__le64 ttl;
- struct ieee80211_hdr hdr[0];
+ struct ieee80211_hdr hdr[];
} __packed; /* TX_CMD_API_S_VER_8 */

/*
@@ -766,8 +766,8 @@ struct iwl_mvm_compressed_ba_notif {
__le32 tx_rate;
__le16 tfd_cnt;
__le16 ra_tid_cnt;
- struct iwl_mvm_compressed_ba_tfd tfd[0];
struct iwl_mvm_compressed_ba_ratid ra_tid[0];
+ struct iwl_mvm_compressed_ba_tfd tfd[];
} __packed; /* COMPRESSED_BA_RES_API_S_VER_4 */

/**
@@ -784,7 +784,7 @@ struct iwl_mac_beacon_cmd_v6 {
__le32 template_id;
__le32 tim_idx;
__le32 tim_size;
- struct ieee80211_hdr frame[0];
+ struct ieee80211_hdr frame[];
} __packed; /* BEACON_TEMPLATE_CMD_API_S_VER_6 */

/**
@@ -805,7 +805,7 @@ struct iwl_mac_beacon_cmd_v7 {
__le32 tim_size;
__le32 ecsa_offset;
__le32 csa_offset;
- struct ieee80211_hdr frame[0];
+ struct ieee80211_hdr frame[];
} __packed; /* BEACON_TEMPLATE_CMD_API_S_VER_7 */

enum iwl_mac_beacon_flags {
@@ -840,7 +840,7 @@ struct iwl_mac_beacon_cmd {
__le32 tim_size;
__le32 ecsa_offset;
__le32 csa_offset;
- struct ieee80211_hdr frame[0];
+ struct ieee80211_hdr frame[];
} __packed; /* BEACON_TEMPLATE_CMD_API_S_VER_10 */

struct iwl_beacon_notif {
--
2.26.0