Skip to contentSkip to conversation

IB/hfi1: Avoid -Wflex-array-member-not-at-end warning

PATCH In review Gustavo A. R. Silva 2 participants 2 messages Mar 27, 2025 – Mar 30, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IB/hfi1: 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.

Move the conflicting declaration to the end of the structure. Notice that struct opa_mad_notice_attr is a flexible structure --a structure that contains a flexible-array member.

Fix the following warning:

drivers/infiniband/hw/hfi1/mad.c:23:36: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

---
 drivers/infiniband/hw/hfi1/mad.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/hfi1/mad.c +3 -1
index b39f63ce6dfc..3f11a90819d1 100644
@@ -20,12 +20,14 @@
 
 struct trap_node {
 	struct list_head list;
-	struct opa_mad_notice_attr data;
 	__be64 tid;
 	int len;
 	u32 retry;
 	u8 in_use;
 	u8 repress;
+
+	/* Must be last --ends in a flexible-array member. */
+	struct opa_mad_notice_attr data;
 };
 
 static int smp_length_check(u32 data_size, u32 request_len)
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Gustavo A. R. Silva

-Wflex-array-member-not-at-end was introduced in GCC-14, and we are getting ready to enable it, globally.

Move the conflicting declaration to the end of the structure. Notice that struct opa_mad_notice_attr is a flexible structure --a structure that contains a flexible-array member.

Quoted 5 lines

Fix the following warning:

drivers/infiniband/hw/hfi1/mad.c:23:36: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Thanks,
Zhu Yanjun

Quoted 24 lines
---
  drivers/infiniband/hw/hfi1/mad.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/hfi1/mad.c +3 -1
index b39f63ce6dfc..3f11a90819d1 100644
@@ -20,12 +20,14 @@
 
  struct trap_node {
  	struct list_head list;
-	struct opa_mad_notice_attr data;
  	__be64 tid;
  	int len;
  	u32 retry;
  	u8 in_use;
  	u8 repress;
+
+	/* Must be last --ends in a flexible-array member. */
+	struct opa_mad_notice_attr data;
  };
 
  static int smp_length_check(u32 data_size, u32 request_len)