Skip to content

Commit 40d51f7

Browse files
GustavoARSilvaKalle Valo
authored andcommitted
wifi: mt76: mt7996: Use DECLARE_FLEX_ARRAY() and fix -Warray-bounds warnings
Transform zero-length arrays `rate`, `adm_stat` and `msdu_cnt` into proper flexible-array members in anonymous union in `struct mt7996_mcu_all_sta_info_event` via the DECLARE_FLEX_ARRAY() helper; and fix multiple -Warray-bounds warnings: drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:544:61: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:551:58: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:553:58: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:530:61: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:538:66: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:540:66: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:520:57: warning: array subscript <unknown> is outside array bounds of 'struct all_sta_trx_rate[0]' [-Warray-bounds=] drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:526:76: warning: array subscript <unknown> is outside array bounds of 'struct all_sta_trx_rate[0]' [-Warray-bounds=] drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:526:76: warning: array subscript <unknown> is outside array bounds of 'struct all_sta_trx_rate[0]' [-Warray-bounds=] drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:526:76: warning: array subscript <unknown> is outside array bounds of 'struct all_sta_trx_rate[0]' [-Warray-bounds=] drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:526:76: warning: array subscript <unknown> is outside array bounds of 'struct all_sta_trx_rate[0]' [-Warray-bounds=] This results in no differences in binary output, helps with the ongoing efforts to globally enable -Warray-bounds. Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://msgid.link/ZXiU9ayVCslt3qiI@work
1 parent 5a17458 commit 40d51f7

File tree

1 file changed

+5
-5
lines changed
  • drivers/net/wireless/mediatek/mt76/mt7996

1 file changed

+5
-5
lines changed

drivers/net/wireless/mediatek/mt76/mt7996/mcu.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,20 +206,20 @@ struct mt7996_mcu_all_sta_info_event {
206206
u8 rsv3[4];
207207

208208
union {
209-
struct all_sta_trx_rate rate[0];
210-
struct {
209+
DECLARE_FLEX_ARRAY(struct all_sta_trx_rate, rate);
210+
DECLARE_FLEX_ARRAY(struct {
211211
__le16 wlan_idx;
212212
u8 rsv[2];
213213
__le32 tx_bytes[IEEE80211_NUM_ACS];
214214
__le32 rx_bytes[IEEE80211_NUM_ACS];
215-
} adm_stat[0] __packed;
215+
} __packed, adm_stat);
216216

217-
struct {
217+
DECLARE_FLEX_ARRAY(struct {
218218
__le16 wlan_idx;
219219
u8 rsv[2];
220220
__le32 tx_msdu_cnt;
221221
__le32 rx_msdu_cnt;
222-
} msdu_cnt[0] __packed;
222+
} __packed, msdu_cnt);
223223
} __packed;
224224
} __packed;
225225

0 commit comments

Comments
 (0)