| To: | Andi Kleen <andi@xxxxxxxxxxxxxx> |
|---|---|
| Subject: | Re: [PATCH v2] xfs: Silence bounds checking compiler warning |
| From: | Al Viro <viro@xxxxxxxxxxxxxxxxxx> |
| Date: | Thu, 23 Jun 2011 18:55:33 +0100 |
| Cc: | Maarten Lankhorst <m.b.lankhorst@xxxxxxxxx>, Alex Elder <aelder@xxxxxxx>, xfs-masters@xxxxxxxxxxx, Linux Kernel Mailing List <linux-kernel@xxxxxxxxxxxxxxx>, xfs@xxxxxxxxxxx |
| In-reply-to: | <m2boxocvb5.fsf@xxxxxxxxxxxxxx> |
| References: | <4E037001.8090306__42924.0493024283$1308849791$gmane$org@xxxxxxxxx> <m2boxocvb5.fsf@xxxxxxxxxxxxxx> |
| Sender: | Al Viro <viro@xxxxxxxxxxxxxxxx> |
| User-agent: | Mutt/1.5.21 (2010-09-15) |
On Thu, Jun 23, 2011 at 10:27:26AM -0700, Andi Kleen wrote: > Maarten Lankhorst <m.b.lankhorst@xxxxxxxxx> writes: > > > gcc with -Warray-bounds generates a false positive on this > > since xfs defines the struct with u8 name[1]; to be able to > > add a tag at the end. > > A better way would be to define it as name[0]. Then the compiler > would know it's a VLA. You may need to check noone relies on > the one byte though. ... 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... |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: [PATCH v2] xfs: Silence bounds checking compiler warning, Andi Kleen |
|---|---|
| Next by Date: | Re: [PATCH v2] xfs: Silence bounds checking compiler warning, Christoph Hellwig |
| Previous by Thread: | Re: [PATCH v2] xfs: Silence bounds checking compiler warning, Andi Kleen |
| Next by Thread: | Re: [PATCH v2] xfs: Silence bounds checking compiler warning, Christoph Hellwig |
| Indexes: | [Date] [Thread] [Top] [All Lists] |