UAPI: net/sched - cxgb4: Fix -Wflex-array-member-not-at-end warning
cover UAPI: net/sched - cxgb4: Fix -Wflex-array-member-not-at-end warning
Small patch series aimed at fixing a -Wflex-array-member-not-at-end warning by creating a new tagged struct within a flexible structure. We then use this new struct type to fix a problematic middle-flex-array declaration in a composite struct.
Gustavo A. R. Silva (2):
UAPI: net/sched: Use __struct_group() in flex struct tc_u32_sel
cxgb4: Avoid -Wflex-array-member-not-at-end warning
.../chelsio/cxgb4/cxgb4_tc_u32_parse.h | 2 +- include/uapi/linux/pkt_cls.h | 23 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/2 UAPI: net/sched: Use __struct_group() in flex struct tc_u32_sel
Use the __struct_group() helper to create a new tagged struct tc_u32_sel_hdr. This structure groups together all the members of the flexible struct tc_u32_sel except the flexible array. As a result, the array is effectively separated from the rest of the members without modifying the memory layout of the flexible structure.
This new tagged struct will be used to fix problematic declarations of middle-flex-arrays in composite structs[1].
[1] https://git.kernel.org/linus/d88cabfd9abc
--- include/uapi/linux/pkt_cls.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
include/uapi/linux/pkt_cls.h +13 -10
@@ -246,16 +246,19 @@ struct tc_u32_key { };struct tc_u32_sel { -unsigned char flags; -unsigned char offshift; -unsigned char nkeys; - -__be16 offmask; -__u16 off; -short offoff; - -short hoff; -__be32 hmask; +/* New members MUST be added within the __struct_group() macro below. */ + __struct_group(tc_u32_sel_hdr, hdr, /* no attrs */, + unsigned char flags; +unsigned char offshift; +unsigned char nkeys; + +__be16 offmask; +__u16 off; +short offoff; + +short hoff; +__be32 hmask; + );struct tc_u32_key keys[]; };
Signature · 1 line
2.34.1
PATCH 2/2 cxgb4: Avoid -Wflex-array-member-not-at-end warning
In reply to Gustavo A. R. Silva-Wflex-array-member-not-at-end was introduced in GCC-14, and we are getting ready to enable it, globally.
Change the type of the middle struct member currently causing trouble from struct tc_u32_sel to struct tc_u32_sel_hdr.
Fix the following warning:
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:245:27: 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_tc_u32_parse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h +1 -1
@@ -242,7 +242,7 @@ struct cxgb4_next_header {* field's value to jump to next header such as IHL field * in IPv4 header. */ -struct tc_u32_sel sel; +struct tc_u32_sel_hdr sel;struct tc_u32_key key;/* location of jump to make */ const struct cxgb4_match_field *jump;
Signature · 1 line
2.34.1
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Tue, 13 Aug 2024 16:13:58 -0600 you wrote:
Small patch series aimed at fixing a -Wflex-array-member-not-at-end warning by creating a new tagged struct within a flexible structure. We then use this new struct type to fix a problematic middle-flex-array declaration in a composite struct.
Gustavo A. R. Silva (2):
UAPI: net/sched: Use__struct_group()in flex structtc_u32_sel
cxgb4: Avoid -Wflex-array-member-not-at-end warning[...]
Here is the summary with links:
- [1/2,next] UAPI: net/sched: Use __struct_group() in flex struct tc_u32_sel
https://git.kernel.org/netdev/net-next/c/216203bdc228 - [2/2,next] cxgb4: Avoid -Wflex-array-member-not-at-end warning https://git.kernel.org/netdev/net-next/c/6c5cdabb3ec3
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html