diff mbox series

[next] sched: act_ct: avoid -Wflex-array-member-not-at-end warning

Message ID ZrDxUhm5bqCKU9a9@cute (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [next] sched: act_ct: avoid -Wflex-array-member-not-at-end warning | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 29 this patch: 29
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 29 this patch: 29
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 29 this patch: 29
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-06--00-00 (tests: 707)

Commit Message

Gustavo A. R. Silva Aug. 5, 2024, 3:35 p.m. UTC
-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 zones_ht_key` is a flexible structure --a structure that
contains a flexible-array member.

Fix the following warning:
net/sched/act_ct.c:57:29: 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>
---
 net/sched/act_ct.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Simon Horman Aug. 7, 2024, 4:18 p.m. UTC | #1
On Mon, Aug 05, 2024 at 09:35:46AM -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.
> 
> Move the conflicting declaration to the end of the structure. Notice
> that `struct zones_ht_key` is a flexible structure --a structure that
> contains a flexible-array member.
> 
> Fix the following warning:
> net/sched/act_ct.c:57:29: 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>
Jakub Kicinski Aug. 9, 2024, 2:46 a.m. UTC | #2
On Mon, 5 Aug 2024 09:35:46 -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.
> 
> Move the conflicting declaration to the end of the structure. Notice
> that `struct zones_ht_key` is a flexible structure --a structure that
> contains a flexible-array member.

I think the flex member is there purely to mark the end of the struct.
You can use offsetofend(zone) instead of offsetof(pad), and delete pad.
Gustavo A. R. Silva Aug. 9, 2024, 3:21 p.m. UTC | #3
On 08/08/24 20:46, Jakub Kicinski wrote:
> On Mon, 5 Aug 2024 09:35:46 -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.
>>
>> Move the conflicting declaration to the end of the structure. Notice
>> that `struct zones_ht_key` is a flexible structure --a structure that
>> contains a flexible-array member.
> 
> I think the flex member is there purely to mark the end of the struct.
> You can use offsetofend(zone) instead of offsetof(pad), and delete pad.

Nice! I'll send v2, shortly.

Thanks
--
Gustavo
diff mbox series

Patch

diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
index 3ba8e7e739b5..b304ef46b5be 100644
--- a/net/sched/act_ct.c
+++ b/net/sched/act_ct.c
@@ -54,9 +54,11 @@  struct tcf_ct_flow_table {
 	struct rcu_work rwork;
 	struct nf_flowtable nf_ft;
 	refcount_t ref;
-	struct zones_ht_key key;
 
 	bool dying;
+
+	/* Must be last - ends in a flex-array member. */
+	struct zones_ht_key key;
 };
 
 static const struct rhashtable_params zones_params = {