summaryrefslogtreecommitdiff
path: root/lib/fts_.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2015-04-27 01:19:03 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2015-04-27 01:24:40 -0700
commite4584a9e26ea39e2f961a700c60f3a10ec07dbb4 (patch)
treeb4056aee3400d84f5e4d75b188471c5cbf7fd790 /lib/fts_.h
parentff714c0a2094bdefd9ed41603493e66aaf285f12 (diff)
downloadgnulib-e4584a9e26ea39e2f961a700c60f3a10ec07dbb4.tar.gz
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.
Diffstat (limited to 'lib/fts_.h')
-rw-r--r--lib/fts_.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/fts_.h b/lib/fts_.h
index bbf64842e4..b9a3f12cca 100644
--- a/lib/fts_.h
+++ b/lib/fts_.h
@@ -51,7 +51,13 @@
# 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
@@ -243,7 +249,7 @@ typedef struct _ftsent {
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