wifi: iwlwifi: mld: Avoid multiple -Wflex-array-member-not-at-end warnings
PATCH 1/1 wifi: iwlwifi: mld: Avoid multiple -Wflex-array-member-not-at-end warnings
Use the DEFINE_RAW_FLEX() helper for on-stack definitions of a flexible structure where the size of the flexible-array member is known at compile-time, and refactor the rest of the code, accordingly.
So, with these changes, fix the following warnings:
drivers/net/wireless/intel/iwlwifi/mld/tlc.c:499: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/intel/iwlwifi/mld/rx.c:1862:41: 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/iwlwifi/mld/d3.c:867:43: 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/iwlwifi/mld/d3.c | 44 ++++++++++---------- drivers/net/wireless/intel/iwlwifi/mld/rx.c | 24 +++++------ drivers/net/wireless/intel/iwlwifi/mld/tlc.c | 23 +++++----- 3 files changed, 44 insertions(+), 47 deletions(-)
drivers/net/wireless/intel/iwlwifi/mld/d3.c +21 -23
@@ -863,23 +863,21 @@ iwl_mld_add_mcast_rekey(struct ieee80211_vif *vif, u32 cipher) {struct ieee80211_key_conf *key_config; -struct { -struct ieee80211_key_conf conf; -u8 key[WOWLAN_KEY_MAX_SIZE ]; - } conf = { - .conf.cipher = cipher, - .conf.keyidx = key_data->id, - }; + DEFINE_RAW_FLEX(struct ieee80211_key_conf, conf, key, + WOWLAN_KEY_MAX_SIZE);int link_id = vif->active_links ?__ffs (vif->active_links) :-1 ; + conf->cipher = cipher; + conf->keyidx = key_data->id; +BUILD_BUG_ON (WLAN_KEY_LEN_CCMP !=WLAN_KEY_LEN_GCMP ); -BUILD_BUG_ON (sizeof (conf.key) <WLAN_KEY_LEN_CCMP ); -BUILD_BUG_ON (sizeof (conf.key) <WLAN_KEY_LEN_GCMP_256 ); -BUILD_BUG_ON (sizeof (conf.key) <WLAN_KEY_LEN_TKIP ); -BUILD_BUG_ON (sizeof (conf.key) <WLAN_KEY_LEN_BIP_GMAC_128 ); -BUILD_BUG_ON (sizeof (conf.key) <WLAN_KEY_LEN_BIP_GMAC_256 ); -BUILD_BUG_ON (sizeof (conf.key) <WLAN_KEY_LEN_AES_CMAC ); -BUILD_BUG_ON (sizeof (conf.key) <sizeof (key_data->key)); +BUILD_BUG_ON (__member_size (conf->key) <WLAN_KEY_LEN_CCMP ); +BUILD_BUG_ON (__member_size (conf->key) <WLAN_KEY_LEN_GCMP_256 ); +BUILD_BUG_ON (__member_size (conf->key) <WLAN_KEY_LEN_TKIP ); +BUILD_BUG_ON (__member_size (conf->key) <WLAN_KEY_LEN_BIP_GMAC_128 ); +BUILD_BUG_ON (__member_size (conf->key) <WLAN_KEY_LEN_BIP_GMAC_256 ); +BUILD_BUG_ON (__member_size (conf->key) <WLAN_KEY_LEN_AES_CMAC ); +BUILD_BUG_ON (__member_size (conf->key) <sizeof (key_data->key));if (!key_data->len)return true;
@@ -887,32 +885,32 @@ iwl_mld_add_mcast_rekey(struct ieee80211_vif *vif,switch (cipher) {case WLAN_CIPHER_SUITE_CCMP :case WLAN_CIPHER_SUITE_GCMP : - conf.conf.keylen =WLAN_KEY_LEN_CCMP ; + conf->keylen =WLAN_KEY_LEN_CCMP ;break ;case WLAN_CIPHER_SUITE_GCMP_256 : - conf.conf.keylen =WLAN_KEY_LEN_GCMP_256 ; + conf->keylen =WLAN_KEY_LEN_GCMP_256 ;break ;case WLAN_CIPHER_SUITE_TKIP : - conf.conf.keylen =WLAN_KEY_LEN_TKIP ; + conf->keylen =WLAN_KEY_LEN_TKIP ;break ;case WLAN_CIPHER_SUITE_BIP_GMAC_128 : - conf.conf.keylen =WLAN_KEY_LEN_BIP_GMAC_128 ; + conf->keylen =WLAN_KEY_LEN_BIP_GMAC_128 ;break ;case WLAN_CIPHER_SUITE_BIP_GMAC_256 : - conf.conf.keylen =WLAN_KEY_LEN_BIP_GMAC_256 ; + conf->keylen =WLAN_KEY_LEN_BIP_GMAC_256 ;break ;case WLAN_CIPHER_SUITE_AES_CMAC : - conf.conf.keylen =WLAN_KEY_LEN_AES_CMAC ; + conf->keylen =WLAN_KEY_LEN_AES_CMAC ;break ;case WLAN_CIPHER_SUITE_BIP_CMAC_256 : - conf.conf.keylen =WLAN_KEY_LEN_BIP_CMAC_256 ; + conf->keylen =WLAN_KEY_LEN_BIP_CMAC_256 ;break ;default :WARN_ON (1 ); } -memcpy (conf.conf.key, key_data->key, conf.conf.keylen); - key_config =ieee80211_gtk_rekey_add (vif, &conf.conf, link_id); +memcpy (conf->key, key_data->key, conf->keylen); + key_config =ieee80211_gtk_rekey_add (vif, conf, link_id);if (IS_ERR (key_config))return false;
drivers/net/wireless/intel/iwlwifi/mld/rx.c +12 -12
@@ -1858,17 +1858,10 @@ void iwl_mld_sync_rx_queues(struct iwl_mld *mld, const void *notif_payload, u32 notif_payload_size) {u8 num_rx_queues = mld->trans->num_rx_queues; -struct { -struct iwl_rxq_sync_cmd sync_cmd; -struct iwl_mld_internal_rxq_notif notif; - } __packed cmd = { - .sync_cmd.rxq_mask =cpu_to_le32 (BIT (num_rx_queues) -1 ), - .sync_cmd.count = -cpu_to_le32 (sizeof (struct iwl_mld_internal_rxq_notif ) + - notif_payload_size), - .notif.type = type, - .notif.cookie = mld->rxq_sync.cookie, - }; + DEFINE_RAW_FLEX(struct iwl_rxq_sync_cmd, cmd, payload, + sizeof(struct iwl_mld_internal_rxq_notif)); +struct iwl_mld_internal_rxq_notif *notif = + (struct iwl_mld_internal_rxq_notif *)cmd->payload;struct iwl_host_cmd hcmd = { .id =WIDE_ID (DATA_PATH_GROUP ,TRIGGER_RX_QUEUES_NOTIF_CMD ), .data[0 ] = &cmd,
@@ -1878,8 +1871,15 @@ void iwl_mld_sync_rx_queues(struct iwl_mld *mld, };int ret; + cmd->rxq_mask =cpu_to_le32 (BIT (num_rx_queues) -1 ); + cmd->count = +cpu_to_le32 (sizeof (struct iwl_mld_internal_rxq_notif ) + + notif_payload_size); + notif->type = type; + notif->cookie = mld->rxq_sync.cookie; +/* size must be a multiple of DWORD */ -if (WARN_ON (cmd.sync_cmd.count &cpu_to_le32 (3 ))) +if (WARN_ON (cmd->count &cpu_to_le32 (3 )))return ; mld->rxq_sync.state = (1 << num_rx_queues) -1 ;
drivers/net/wireless/intel/iwlwifi/mld/tlc.c +11 -12
@@ -495,20 +495,19 @@ static void iwl_mld_send_tlc_cmd(struct iwl_mld *mld,int iwl_mld_send_tlc_dhc (struct iwl_mld *mld,u8 sta_id,u32 type,u32 data) { -struct { -struct iwl_dhc_cmd dhc; -struct iwl_dhc_tlc_cmd tlc; - } __packed cmd = { - .tlc.sta_id = sta_id, - .tlc.type =cpu_to_le32 (type), - .tlc.data[0 ] =cpu_to_le32 (data), - .dhc.length =cpu_to_le32 (sizeof (cmd.tlc) >>2 ), - .dhc.index_and_mask = -cpu_to_le32 (DHC_TABLE_INTEGRATION |DHC_TARGET_UMAC | -DHC_INTEGRATION_TLC_DEBUG_CONFIG ), - }; + DEFINE_RAW_FLEX(struct iwl_dhc_cmd, cmd, data, + sizeof(struct iwl_dhc_tlc_cmd)); +struct iwl_dhc_tlc_cmd *tlc = (struct iwl_dhc_tlc_cmd *)cmd->data;int ret; + tlc->sta_id = sta_id; + tlc->type =cpu_to_le32 (type); + tlc->data[0 ] =cpu_to_le32 (data); + cmd->length =cpu_to_le32 (sizeof (*tlc) >>2 ); + cmd->index_and_mask = +cpu_to_le32 (DHC_TABLE_INTEGRATION |DHC_TARGET_UMAC | +DHC_INTEGRATION_TLC_DEBUG_CONFIG ); + ret = iwl_mld_send_cmd_with_flags_pdu(mld, WIDE_ID(IWL_ALWAYS_LONG_GROUP, DEBUG_HOST_COMMAND),
Signature · 1 line
2.43.0