[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250908125300.25a2f475@pumpkin>
Date: Mon, 8 Sep 2025 12:53:00 +0100
From: David Laight <david.laight.linux@...il.com>
To: "Gustavo A. R. Silva" <gustavo@...eddedor.com>
Cc: Michal Koutný <mkoutny@...e.com>, Tejun Heo
 <tj@...nel.org>, Johannes Weiner <hannes@...xchg.org>,
 cgroups@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
 linux-hardening@...r.kernel.org, "Gustavo A. R. Silva"
 <gustavoars@...nel.org>, Chen Ridong <chenridong@...weicloud.com>
Subject: Re: [RFC] cgroup: Avoid thousands of -Wflex-array-member-not-at-end
 warnings
On Tue, 2 Sep 2025 14:37:40 +0200
"Gustavo A. R. Silva" <gustavo@...eddedor.com> wrote:
> On 9/2/25 13:17, Michal Koutný wrote:
> > On Tue, Sep 02, 2025 at 09:56:34AM +0200, "Gustavo A. R. Silva" <gustavo@...eddedor.com> wrote:  
... 
> > 
> > (You seem to be well versed with flex arrays, I was wondering if
> > something like this could be rearranged to make it work (assuming the
> > union is at the end of its containers):
> > 
> > 	union {
> > 		struct cgroup *ancestors[];
> > 		struct {
> > 			struct cgroup *_root_ancestor;
> > 			struct cgroup *_low_ancestors[];
> > 		};
> > 	};
> > )  
> 
> Yep, that works (as long as it's always at the very end of any container
> or ends last in any nested structs, for instance in struct cgroup_root,
> it must also be at the end) for GCC-15+, but for older versions of GCC we
> have to use the DECLARE_FLEX_ARRAY() helper as below:
Could the warning be disabled for 'older versions of gcc'?
A build time warning doesn't need to happen for all builds.
	David
> 
>          union {
>                  /* All ancestors including self */
>                  DECLARE_FLEX_ARRAY(struct cgroup *, ancestors);
>                  struct {
>                          struct cgroup *_root_ancestor;
>                          struct cgroup *_low_ancestors[];
>                  };
>          };
> 
> Thanks
> -Gustavo
> 
Powered by blists - more mailing lists
 
