Message ID | ZrD8vpfiYugd0cPQ@cute (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [next] cxgb4: Avoid -Wflex-array-member-not-at-end warning | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
On Mon, Aug 05, 2024 at 10:24:30AM -0600, Gustavo A. R. Silva wrote: > -Wflex-array-member-not-at-end was introduced in GCC-14, and we are > getting ready to enable it, globally. > > So, in order to avoid ending up with a flexible-array member in the > middle of multiple other structs, we 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. > We then change the type of the middle struct member currently causing > trouble from `struct tc_u32_sel` to `struct tc_u32_sel_hdr`. > > This approach avoids having to implement `struct tc_u32_sel_hdr` > as a completely separate structure, thus preventing having to maintain > two independent but basically identical structures, closing the door > to potential bugs in the future. > > So, with these changes, 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] > > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: Simon Horman <horms@kernel.org>
On Mon, 5 Aug 2024 10:24:30 -0600 Gustavo A. R. Silva wrote: > Subject: [PATCH][next] cxgb4: Avoid -Wflex-array-member-not-at-end warning > Date: Mon, 5 Aug 2024 10:24:30 -0600 > .../chelsio/cxgb4/cxgb4_tc_u32_parse.h | 2 +- > include/uapi/linux/pkt_cls.h | 23 +++++++++++-------- Took me a minute to realize you're changing uAPI. Please fix the subject.
>> .../chelsio/cxgb4/cxgb4_tc_u32_parse.h | 2 +- >> include/uapi/linux/pkt_cls.h | 23 +++++++++++-------- > > Took me a minute to realize you're changing uAPI. > Please fix the subject. What would be a preferred subject? -- Gustavo
On Thu, 8 Aug 2024 12:41:32 -0600 Gustavo A. R. Silva wrote: > >> .../chelsio/cxgb4/cxgb4_tc_u32_parse.h | 2 +- > >> include/uapi/linux/pkt_cls.h | 23 +++++++++++-------- > > > > Took me a minute to realize you're changing uAPI. > > Please fix the subject. > > What would be a preferred subject? The point is that include/uapi/linux/pkt_cls.h is the more important change. net/sched, based on: git log --oneline -- include/uapi/linux/pkt_cls.h 11036bd7a0b3 net/sched: cls_flower: rework TCA_FLOWER_KEY_ENC_FLAGS usage bfda5a63137b net/sched: flower: define new tunnel flags 6e5c85c003e4 net/sched: flower: refactor control flag definitions 1d17568e74de net/sched: cls_flower: add support for matching tunnel control flags 6dd514f48110 pfcp: always set pfcp metadata 82b2545ed9a4 net/sched: Remove uapi support for tcindex classifier 41bc3e8fc1f7 net/sched: Remove uapi support for rsvp classifier ba24ea129126 net/sched: Retire ipt action 35b1b1fd9638 Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 4c13eda757e3 tc: flower: support for SPI 4d50e50045aa net: flower: fix stack-out-of-bounds in fl_set_key_cfm() 7cfffd5fed3e net: flower: add support for matching cfm fields 1a432018c0cd net/sched: flower: Allow matching on layer 2 miss 8b189ea08c33 net/sched: flower: Add L2TPv3 filter f86d1fbbe785 Merge tag 'net-next-6.0' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 5008750eff5d net/sched: flower: Add PPPoE filter 94dfc73e7cf4 treewide: uapi: Replace zero-length arrays with flexible-array members b40003128226 net/sched: flower: Add number of vlan tags filter e3acda7ade0a net/sched: Allow flower to match on GTP options You can throw in uAPI somewhere in the subject, too
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h index 9050568a034c..64663112cad8 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h @@ -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; diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h index d36d9cdf0c00..2c32080416b5 100644 --- a/include/uapi/linux/pkt_cls.h +++ b/include/uapi/linux/pkt_cls.h @@ -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[]; };
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are getting ready to enable it, globally. So, in order to avoid ending up with a flexible-array member in the middle of multiple other structs, we 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. We then change the type of the middle struct member currently causing trouble from `struct tc_u32_sel` to `struct tc_u32_sel_hdr`. This approach avoids having to implement `struct tc_u32_sel_hdr` as a completely separate structure, thus preventing having to maintain two independent but basically identical structures, closing the door to potential bugs in the future. So, with these changes, 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] Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> --- .../chelsio/cxgb4/cxgb4_tc_u32_parse.h | 2 +- include/uapi/linux/pkt_cls.h | 23 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-)