public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] wifi: iwlwifi: mld: tlc: Avoid a -Wflex-array-member-not-at-end warning
@ 2026-04-08 20:19 Gustavo A. R. Silva
  0 siblings, 0 replies; only message in thread
From: Gustavo A. R. Silva @ 2026-04-08 20:19 UTC (permalink / raw)
  To: Miri Korenblit
  Cc: linux-wireless, linux-kernel, Gustavo A. R. Silva,
	linux-hardening

-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_dhc_cmd,
so the new header type struct iwl_dhc_cmd_hdr can be referenced
independently (of the flexible-array member), and fix the following
warning:

drivers/net/wireless/intel/iwlwifi/mld/tlc.c:544:36: 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_dhc_cmd. Any new members must be added to
struct iwl_dhc_cmd_hdr instead. This preserves the expected memory
layout between the header and the flexible-array member.

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 .../net/wireless/intel/iwlwifi/fw/api/dhc.h   | 21 ++++++++++++++++---
 drivers/net/wireless/intel/iwlwifi/mld/tlc.c  |  2 +-
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/dhc.h b/drivers/net/wireless/intel/iwlwifi/fw/api/dhc.h
index b6d79c678cd8..bce4097fee27 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/dhc.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/dhc.h
@@ -51,7 +51,7 @@ enum iwl_dhc_umac_integration_table {
 #define DHC_TARGET_UMAC BIT(27)
 
 /**
- * struct iwl_dhc_cmd - debug host command
+ * struct iwl_dhc_cmd_hdr - debug host command header
  * @length: length in DWs of the data structure that is concatenated to the end
  *	of this struct
  * @index_and_mask: bit 31 is 1 for data set operation else it's 0
@@ -62,14 +62,29 @@ enum iwl_dhc_umac_integration_table {
  *	bit 26 is 0 if the cmd targeted to LMAC0 and 1 if targeted to LMAC1,
  *	relevant only if bit 27 set to 0
  *	bits 0-25 is a specific entry index in the table specified in bits 28-30
+ */
+struct iwl_dhc_cmd_hdr {
+	__le32 length;
+	__le32 index_and_mask;
+} __packed;
+
+/**
+ * struct iwl_dhc_cmd - debug host command
+ *
+ * (NOTE: New members MUST NOT be added directly to this struct. Add them to
+ * struct iwl_dhc_cmd_hdr instead.)
  *
+ * @iwl_dhc_cmd_hdr: anonymous embedded header - members are directly
+ *		     accessible
  * @data: the concatenated data.
+ *
  */
 struct iwl_dhc_cmd {
-	__le32 length;
-	__le32 index_and_mask;
+	struct iwl_dhc_cmd_hdr;
 	__le32 data[];
 } __packed; /* DHC_CMD_API_S */
+static_assert(offsetof(struct iwl_dhc_cmd, data) == sizeof(struct iwl_dhc_cmd_hdr),
+	      "New members must be added to struct iwl_dhc_cmd_hdr instead.");
 
 /**
  * struct iwl_dhc_payload_hdr - DHC payload header
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/tlc.c b/drivers/net/wireless/intel/iwlwifi/mld/tlc.c
index 78d6162d9297..b6f41a8c138e 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/tlc.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/tlc.c
@@ -619,7 +619,7 @@ 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_cmd_hdr dhc;
 		struct iwl_dhc_tlc_cmd tlc;
 	} __packed cmd = {
 		.tlc.sta_id = sta_id,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-04-08 20:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-08 20:19 [PATCH][next] wifi: iwlwifi: mld: tlc: Avoid a -Wflex-array-member-not-at-end warning Gustavo A. R. Silva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox