Linux cgroups development
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Cc: "Michal Koutný" <mkoutny@suse.com>, "Tejun Heo" <tj@kernel.org>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	cgroups@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	linux-hardening@vger.kernel.org,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	"Chen Ridong" <chenridong@huaweicloud.com>
Subject: Re: [RFC] cgroup: Avoid thousands of -Wflex-array-member-not-at-end warnings
Date: Mon, 8 Sep 2025 12:53:00 +0100	[thread overview]
Message-ID: <20250908125300.25a2f475@pumpkin> (raw)
In-Reply-To: <5fb74444-2fbb-476e-b1bf-3f3e279d0ced@embeddedor.com>

On Tue, 2 Sep 2025 14:37:40 +0200
"Gustavo A. R. Silva" <gustavo@embeddedor.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@embeddedor.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
> 


      reply	other threads:[~2025-09-08 11:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-30 13:30 [RFC] cgroup: Avoid thousands of -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
2025-09-01  1:29 ` Chen Ridong
2025-09-01  7:44   ` Gustavo A. R. Silva
2025-09-01 13:37 ` Michal Koutný
2025-09-01 15:21   ` Gustavo A. R. Silva
2025-09-01 15:44     ` Gustavo A. R. Silva
2025-09-01 18:04       ` Michal Koutný
2025-09-01 17:58     ` Michal Koutný
2025-09-02  7:56       ` Gustavo A. R. Silva
2025-09-02 11:17         ` Michal Koutný
2025-09-02 12:37           ` Gustavo A. R. Silva
2025-09-08 11:53             ` David Laight [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250908125300.25a2f475@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=cgroups@vger.kernel.org \
    --cc=chenridong@huaweicloud.com \
    --cc=gustavo@embeddedor.com \
    --cc=gustavoars@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkoutny@suse.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox