Re: [PATCH] staging: greybus: Replace zero-length array with flexible-array

From: Greg Kroah-Hartman
Date: Wed May 13 2020 - 12:07:54 EST


On Wed, May 13, 2020 at 05:48:07PM +0200, Johan Hovold wrote:
> On Wed, May 13, 2020 at 05:39:18PM +0200, Greg Kroah-Hartman wrote:
> > On Wed, May 13, 2020 at 05:03:43PM +0200, Johan Hovold wrote:
> > > On Thu, May 07, 2020 at 01:53:18PM -0500, Gustavo A. R. Silva wrote:
> > > > The current codebase makes use of the zero-length array language
> > > > extension to the C90 standard, but the preferred mechanism to declare
> > > > variable-length types such as these ones is a flexible array member[1][2],
> > > > introduced in C99:
> > > >
> > > > struct foo {
> > > > int stuff;
> > > > struct boo array[];
> > > > };
>
> > > > drivers/greybus/arpc.h | 2 -
> > > > include/linux/greybus/greybus_protocols.h | 44 +++++++++++++++---------------
> > >
> > > I noticed Greg just applied this one to his -testing branch, but do we
> > > really want this in greybus_protocols.h, which is meant to be shared
> > > with the firmware side? Perhaps not an issue, just figured I'd point
> > > this out.
> >
> > Why not, it should be the same thing, right? No logic has changed that
> > I see.
>
> Yes, the structure's the same, but the firmware toolchain may not
> expect flexible arrays. I believe we're holding back on these changes
> for uapi headers as well for that reason?
>
> Again, perhaps not an issue. We can just mandate fw toolchains that
> support C99 if you want to use an unmodified header, I guess.

I think we can mandate that for now, let's see if anyone actually builds
firmware against this header file anymore :)

greg k-h