Re: [rfc] removing/conditionalising WERROR= in Makefiles

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Fri, 30 Dec 2011 18:04:59 +0100
On 2011-12-30 14:28, David Chisnall wrote:
> On 30 Dec 2011, at 13:06, Dimitry Andric wrote:
>
>>   sys/gnu/fs/xfs/xfs_dir2_block.c:1149:17: warning: array index of '1' indexes past the end of an array (that contains 1 element) [-Warray-bounds]
>
> I recall some discussion of this warning on the clang list a few months ago, and I believe that it should now only appear if you are compiling in a C99 or C11 dialect mode (the rationale is that any variable-length structures in C99 should be using a zero-sized array as the final element, while C89 lacked any ability to do this).

Yes, that is perfectly fine, but the xfs code defines the struct in
question as follows:

/*
  * Active entry in a data block.  Aligned to 8 bytes.
  * Tag appears as the last 2 bytes.
  */
typedef struct xfs_dir2_data_entry {
         xfs_ino_t               inumber;        /* inode number */
         __uint8_t               namelen;        /* name length */
         __uint8_t               name[1];        /* name bytes, no null */
                                                 /* variable offset */
         xfs_dir2_data_off_t     tag;            /* starting offset of us */
} xfs_dir2_data_entry_t;

E.g there *is* an overrun, but maybe it was really supposed to be like
that.  Meanwhile, upstream has apparently caught on:

   http://oss.sgi.com/archives/xfs/2011-07/msg00024.html
Received on Fri Dec 30 2011 - 16:04:58 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:22 UTC