All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: kbuild-all@lists.01.org
Subject: Re: [peterz-queue:perf/core 26/39] arch/x86/include/asm/perf_event.h:290:19: error: flexible array member in a struct with no named members
Date: Tue, 07 Jul 2020 16:44:56 +0200	[thread overview]
Message-ID: <20200707144456.GP4800@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20200707135110.GA11125@embeddedor>

[-- Attachment #1: Type: text/plain, Size: 1829 bytes --]

On Tue, Jul 07, 2020 at 08:51:10AM -0500, Gustavo A. R. Silva wrote:
> On Tue, Jul 07, 2020 at 12:24:43PM +0200, Peter Zijlstra wrote:
> > On Mon, Jul 06, 2020 at 09:08:41PM -0400, Liang, Kan wrote:
> > 
> > > >     288	
> > > >     289	struct pebs_lbr {
> > > >   > 290		struct lbr_entry lbr[]; /* Variable length */
> > > >     291	};
> > > >     292	
> > > 
> > > The struct pebs_lbr only has one member. To fix the warning, it seems we
> > > have to define the struct as below.
> > > 
> > > 
> > > diff --git a/arch/x86/include/asm/perf_event.h
> > > b/arch/x86/include/asm/perf_event.h
> > > index 2338200..a387e14 100644
> > > --- a/arch/x86/include/asm/perf_event.h
> > > +++ b/arch/x86/include/asm/perf_event.h
> > > @@ -283,7 +283,7 @@ struct pebs_xmm {
> > >  };
> > > 
> > >  struct pebs_lbr {
> > > -	struct lbr_entry lbr[]; /* Variable length */
> > > +	struct lbr_entry lbr[0]; /* Variable length */
> > >  };
> > > 
> > 
> > Right, but then we get trouble like the below again. There's basically
> 
> Yep, zero-length and one-element arrays are being deprecated[1].
> 
> > no good solution here :-(
> > 
> > Gustavo, any clues?
> > 
> 
> Yep; the issue is that "Flexible array members may only appear as the
> last member of a struct that is otherwise non-empty"[2].
> 
> The solution is to declare something like this:
> 
> struct pebs_lbr {
> 	size_t num_lbr; /* count for number of lbr entries */
> 	struct lbr_entry lbr[];
> };
> 

Can't.. this is hardware provided layout. The thing is that the array
size is variable, so [0] or [] would be correct.

That said, Kan, I suppose we can simply remove struct pebs_lbr and use
struct lbr_entry * directly. There is very little actual point in having
struct pebs_lbr.

I'll frob the patches and push out again.

  reply	other threads:[~2020-07-07 14:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06 19:39 [peterz-queue:perf/core 26/39] arch/x86/include/asm/perf_event.h:290:19: error: flexible array member in a struct with no named members kernel test robot
2020-07-07  1:08 ` Liang, Kan
2020-07-07 10:24   ` Peter Zijlstra
2020-07-07 13:51     ` Gustavo A. R. Silva
2020-07-07 14:44       ` Peter Zijlstra [this message]
2020-07-07 14:55         ` Liang, Kan
2020-07-07 14:50       ` Liang, Kan
2020-07-07 15:05         ` Gustavo A. R. Silva
2020-07-07 15:24           ` Liang, Kan
2020-07-07 17:09             ` Peter Zijlstra

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=20200707144456.GP4800@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=kbuild-all@lists.01.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.