Skip to contentSkip to conversation

ethtool: Avoid -Wflex-array-member-not-at-end warning

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

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

PATCH 1/1 ethtool: 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 ethtool_dump is a flexible structure --a structure that contains a flexible-array member.

Fix the following warning:
./drivers/net/ethernet/chelsio/cxgb4/cxgb4.h:1215:29: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +4 -3
index fca9533bc011..996769857a12 100644
@@ -1211,9 +1211,6 @@ struct adapter {
 	struct timer_list flower_stats_timer;
 	struct work_struct flower_stats_work;
 
-	/* Ethtool Dump */
-	struct ethtool_dump eth_dump;
-
 	/* HMA */
 	struct hma_data hma;
 
@@ -1233,6 +1230,10 @@ struct adapter {
 
 	/* Ethtool n-tuple */
 	struct cxgb4_ethtool_filter *ethtool_filters;
+
+	/* Ethtool Dump */
+	/* Must be last - ends in a flex-array member. */
+	struct ethtool_dump eth_dump;
 };
 
 /* Support for "sched-class" command to allow a TX Scheduling Class to be
Signature · 1 line
2.34.1
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 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 ethtool_dump is a flexible structure --a structure that contains a flexible-array member.

Fix the following warning:
./drivers/net/ethernet/chelsio/cxgb4/cxgb4.h:1215:29: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

reviewer
#2 lore raw
Quoted 8 lines · Simon Horman
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 ethtool_dump is a flexible structure --a structure that contains a flexible-array member.

Quoted 6 lines
Quoted 4 lines

Fix the following warning:
./drivers/net/ethernet/chelsio/cxgb4/cxgb4.h:1215:29: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Sorry, one minor nit, after the fact.

cxgb4 would probably be a better prefix than ethtool for this patch. But then it would conflict, by name, with

- [PATCH] cxgb4: Avoid -Wflex-array-member-not-at-end warning
https://lore.kernel.org/all/ZrD8vpfiYugd0cPQ@cute/