Skip to contentSkip to conversation

net: atlantic: Aavoid -Wflex-array-member-not-at-end warnings

PATCH In review Gustavo A. R. Silva 3 participants 3 messages Aug 5, 2024 – Aug 6, 2024

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

PATCH 1/1 net: atlantic: Aavoid -Wflex-array-member-not-at-end warnings

-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 hw_atl_utils_fw_rpc ends in a flexible-array member through struct offload_info fw2x_offloads;

Fix the following warnings:
drivers/net/ethernet/aquantia/atlantic/aq_hw.h:197:36: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/net/ethernet/aquantia/atlantic/hw_atl/../aq_hw.h:197:36: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

---
 drivers/net/ethernet/aquantia/atlantic/aq_hw.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +3 -1
index f010bda61c96..a66cd784f90e 100644
@@ -194,10 +194,12 @@ struct aq_hw_s {
 	u32 rpc_addr;
 	u32 settings_addr;
 	u32 rpc_tid;
-	struct hw_atl_utils_fw_rpc rpc;
 	s64 ptp_clk_offset;
 	u16 phy_id;
 	void *priv;
+
+	/* Must be last - ends in a flex-array member. */
+	struct hw_atl_utils_fw_rpc rpc;
 };
 
 struct aq_ring_s;
Signature · 1 line
2.34.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 hw_atl_utils_fw_rpc ends in a flexible-array member

Fix the following warnings:

Quoted 7 lines

drivers/net/ethernet/aquantia/atlantic/aq_hw.h:197:36: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

drivers/net/ethernet/aquantia/atlantic/hw_atl/../aq_hw.h:197:36: warning:
structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Hi Gustavo!

I was abit curious about this variable length structure, because it looks strange and not actually used by driver.

I've cross checked, and its really some outdated declaration. The structure is never used as as a flex sized struct.

So better would be to do just this:

drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h +0 -1
@@ -226,7 +226,6 @@ struct __packed offload_info {
        struct offload_port_info ports;
        struct offload_ka_info kas;
        struct offload_rr_info rrs;
-       u8 buf[];
 };
 

Let me know if you want to submit this, or I can do this as well.

Regards,
Igor

#2 lore raw
Quoted 18 lines · Igor Russkikh
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 hw_atl_utils_fw_rpc ends in a flexible-array member

Fix the following warnings:

Quoted 7 lines

drivers/net/ethernet/aquantia/atlantic/aq_hw.h:197:36: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

drivers/net/ethernet/aquantia/atlantic/hw_atl/../aq_hw.h:197:36: warning:
structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Quoted 5 lines

Hi Gustavo!

I was abit curious about this variable length structure, because it looks strange and not actually used by driver.

I've cross checked, and its really some outdated declaration. The structure is never used as as a flex sized struct.

Oh, this is great to know. Thanks for looking into this!

Quoted 12 lines

So better would be to do just this:

drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h +0 -1
@@ -226,7 +226,6 @@ struct __packed offload_info {
         struct offload_port_info ports;
         struct offload_ka_info kas;
         struct offload_rr_info rrs;
-       u8 buf[];
  };
 
Quoted 2 lines

Let me know if you want to submit this, or I can do this as well.

Feel free to send a patch if you wish. :)

Thanks!
--
Gustavo