Re: [PATCH v2] xfs: Silence bounds checking compiler warning

Christoph Hellwig
2011-06-23T18:13:26Z

On Thu, Jun 23, 2011 at 06:55:33PM +0100, Al Viro wrote:
> ... and even better is to write in real C and have u8 name[]; in the
> end of your structure. That's the standard C99 for this kind of thing
> (see 6.7.2.1p2, p16). Zero-sized array is a gccism predating standard
> flexible array members and since the standard syntax is accepted by
> any gcc version that might be recent enough to build the kernel...

The situation is even more nasty - the one sized fake flex-array
actually is in the middle of the structure. Besides sizeof-expressions
taking the one member array into account only members before the
variable sized array are used. I've started a series cleaning up the
few structures that were done that way (for whatever reason), but it's
pretty intrusive. I don't think papering over these warnings at this
point is a good idea.