+2015-04-27 Paul Eggert <eggert@cs.ucla.edu>
+
+ fts: port to GCC 5.1 with --enable-gcc-warnings
+ Without this fix, GCC 5.1 (correctly) warns about a subscript
+ error on the fts_name component of FTSENT. It's actually a
+ flexible member, so define it that way on C99 or later hosts.
+ * lib/fts.c (fts_alloc): Use offsetof, not sizeof, for a
+ structure that now has a flexible array member.
+ * lib/fts_.h (__FLEXIBLE_ARRAY_MEMBER): New macro.
+ (FTSENT): fts_name is now flexible on C99-or-later platforms.
+ * modules/fts (Depends-on): Add flexmember.
+
2015-04-26 Paul Eggert <eggert@cs.ucla.edu>
file-has-acl: port to CentOS 6
* The file name is a variable length array. Allocate the FTSENT
* structure and the file name in one chunk.
*/
- len = sizeof(FTSENT) + namelen;
+ len = offsetof(FTSENT, fts_name) + namelen + 1;
if ((p = malloc(len)) == NULL)
return (NULL);
# ifdef _LIBC
# include <features.h>
+# if __STDC_VERSION__ < 199901L
+# define __FLEXIBLE_ARRAY_MEMBER 1
+# else
+# define __FLEXIBLE_ARRAY_MEMBER
+# endif
# else
+# define __FLEXIBLE_ARRAY_MEMBER FLEXIBLE_ARRAY_MEMBER
# undef __THROW
# define __THROW
# undef __BEGIN_DECLS
unsigned short int fts_instr; /* fts_set() instructions */
struct stat fts_statp[1]; /* stat(2) information */
- char fts_name[1]; /* file name */
+ char fts_name[__FLEXIBLE_ARRAY_MEMBER]; /* file name */
} FTSENT;
#ifndef __GNUC_PREREQ