From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============0569058853331595337==" MIME-Version: 1.0 From: Peter Zijlstra 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 Message-ID: <20200707144456.GP4800@hirez.programming.kicks-ass.net> In-Reply-To: <20200707135110.GA11125@embeddedor> List-Id: --===============0569058853331595337== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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. --===============0569058853331595337==--