diff mbox series

[next] wifi: iwlwifi: mvm: Avoid -Wflex-array-member-not-at-end warning

Message ID Z-SV8gb6MuZJmmhe@kspp (mailing list archive)
State New
Delegated to: Johannes Berg
Headers show
Series [next] wifi: iwlwifi: mvm: Avoid -Wflex-array-member-not-at-end warning | expand

Checks

Context Check Description
wifibot/fixes_present success Fixes tag not required for -next series
wifibot/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
wifibot/tree_selection success Guessed tree name to be wireless-next
wifibot/ynl success Generated files up to date; no warnings/errors; no diff in generated;
wifibot/build_clang success Errors and warnings before: 0 this patch: 0
wifibot/build_32bit success Errors and warnings before: 0 this patch: 0
wifibot/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
wifibot/build_clang_rust success No Rust files in patch. Skipping build
wifibot/build_tools success No tools touched, skip
wifibot/check_selftest success No net selftest shell script
wifibot/checkpatch success total: 0 errors, 0 warnings, 0 checks, 44 lines checked
wifibot/deprecated_api success None detected
wifibot/header_inline success No static functions without inline keyword in header files
wifibot/kdoc success Errors and warnings before: 0 this patch: 0
wifibot/source_inline success Was 0 now: 0
wifibot/verify_fixes success No Fixes tag
wifibot/verify_signedoff success Signed-off-by tag matches author and committer

Commit Message

Gustavo A. R. Silva March 27, 2025, 12:04 a.m. UTC
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
getting ready to enable it, globally.

Use the `DEFINE_RAW_FLEX()` helper for an on-stack definition 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 warning:

drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c:6430:41: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 25 +++++++++----------
 1 file changed, 12 insertions(+), 13 deletions(-)

Comments

Korenblit, Miriam Rachel March 30, 2025, 4:32 a.m. UTC | #1
> -----Original Message-----
> From: Gustavo A. R. Silva <gustavoars@kernel.org>
> Sent: Thursday, 27 March 2025 2:04
> To: Korenblit, Miriam Rachel <miriam.rachel.korenblit@intel.com>; Johannes
> Berg <johannes@sipsolutions.net>
> Cc: linux-wireless@vger.kernel.org; linux-kernel@vger.kernel.org; Gustavo A. R.
> Silva <gustavoars@kernel.org>; linux-hardening@vger.kernel.org
> Subject: [PATCH][next] wifi: iwlwifi: mvm: Avoid -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 the `DEFINE_RAW_FLEX()` helper for an on-stack definition 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 warning:
> 
> drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c:6430:41: warning: structure
> containing a flexible array member is not at the end of another structure [-Wflex-
> array-member-not-at-end]
> 
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> ---
>  .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 25 +++++++++----------
>  1 file changed, 12 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
> b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
> index 1e916a0ce082..5d8f50a455d7 100644
> --- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
> +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
> @@ -6426,17 +6426,10 @@ void iwl_mvm_sync_rx_queues_internal(struct
> iwl_mvm *mvm,
>  				     bool sync,
>  				     const void *data, u32 size)
>  {
> -	struct {
> -		struct iwl_rxq_sync_cmd cmd;
> -		struct iwl_mvm_internal_rxq_notif notif;
> -	} __packed cmd = {
> -		.cmd.rxq_mask = cpu_to_le32(BIT(mvm->trans-
> >num_rx_queues) - 1),
> -		.cmd.count =
> -			cpu_to_le32(sizeof(struct iwl_mvm_internal_rxq_notif)
> +
> -				    size),
> -		.notif.type = type,
> -		.notif.sync = sync,
> -	};
> +	DEFINE_RAW_FLEX(struct iwl_rxq_sync_cmd, cmd, payload,
> +			sizeof(struct iwl_mvm_internal_rxq_notif));
> +	struct iwl_mvm_internal_rxq_notif *notif =
> +			(struct iwl_mvm_internal_rxq_notif *)cmd->payload;
>  	struct iwl_host_cmd hcmd = {
>  		.id = WIDE_ID(DATA_PATH_GROUP,
> TRIGGER_RX_QUEUES_NOTIF_CMD),
>  		.data[0] = &cmd,
> @@ -6447,15 +6440,21 @@ void iwl_mvm_sync_rx_queues_internal(struct
> iwl_mvm *mvm,
>  	};
>  	int ret;
> 
> +	cmd->rxq_mask = cpu_to_le32(BIT(mvm->trans->num_rx_queues) - 1);
> +	cmd->count = cpu_to_le32(sizeof(struct iwl_mvm_internal_rxq_notif) +
> +				 size);
> +	notif->type = type;
> +	notif->sync = sync;
> +
>  	/* size must be a multiple of DWORD */
> -	if (WARN_ON(cmd.cmd.count & cpu_to_le32(3)))
> +	if (WARN_ON(cmd->count & cpu_to_le32(3)))
>  		return;
> 
>  	if (!iwl_mvm_has_new_rx_api(mvm))
>  		return;
> 
>  	if (sync) {
> -		cmd.notif.cookie = mvm->queue_sync_cookie;
> +		notif->cookie = mvm->queue_sync_cookie;
>  		mvm->queue_sync_state = (1 << mvm->trans->num_rx_queues)
> - 1;
>  	}
> 
> --
> 2.43.0
Acked-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
diff mbox series

Patch

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index 1e916a0ce082..5d8f50a455d7 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -6426,17 +6426,10 @@  void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm *mvm,
 				     bool sync,
 				     const void *data, u32 size)
 {
-	struct {
-		struct iwl_rxq_sync_cmd cmd;
-		struct iwl_mvm_internal_rxq_notif notif;
-	} __packed cmd = {
-		.cmd.rxq_mask = cpu_to_le32(BIT(mvm->trans->num_rx_queues) - 1),
-		.cmd.count =
-			cpu_to_le32(sizeof(struct iwl_mvm_internal_rxq_notif) +
-				    size),
-		.notif.type = type,
-		.notif.sync = sync,
-	};
+	DEFINE_RAW_FLEX(struct iwl_rxq_sync_cmd, cmd, payload,
+			sizeof(struct iwl_mvm_internal_rxq_notif));
+	struct iwl_mvm_internal_rxq_notif *notif =
+			(struct iwl_mvm_internal_rxq_notif *)cmd->payload;
 	struct iwl_host_cmd hcmd = {
 		.id = WIDE_ID(DATA_PATH_GROUP, TRIGGER_RX_QUEUES_NOTIF_CMD),
 		.data[0] = &cmd,
@@ -6447,15 +6440,21 @@  void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm *mvm,
 	};
 	int ret;
 
+	cmd->rxq_mask = cpu_to_le32(BIT(mvm->trans->num_rx_queues) - 1);
+	cmd->count = cpu_to_le32(sizeof(struct iwl_mvm_internal_rxq_notif) +
+				 size);
+	notif->type = type;
+	notif->sync = sync;
+
 	/* size must be a multiple of DWORD */
-	if (WARN_ON(cmd.cmd.count & cpu_to_le32(3)))
+	if (WARN_ON(cmd->count & cpu_to_le32(3)))
 		return;
 
 	if (!iwl_mvm_has_new_rx_api(mvm))
 		return;
 
 	if (sync) {
-		cmd.notif.cookie = mvm->queue_sync_cookie;
+		notif->cookie = mvm->queue_sync_cookie;
 		mvm->queue_sync_state = (1 << mvm->trans->num_rx_queues) - 1;
 	}