This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Remove non-standard initialisation of flexible array member


Standard C does not allow initialisation of flexible array member.  GNU
C does, but it has always been broken (see
<http://gcc.gnu.org/PR28865>).  This is a wrong-code bug for powerpc
(the computed object addresses are wrong).  Avoid using the GNU
extension, similar to what is already done in nss/nss_db/db-init.c.

Andreas.

	* nss/nss_files/files-init.c (TF): Don't initialize flexible array
	member.
	(_nss_files_init): Set it here.
---
 nss/nss_files/files-init.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/nss/nss_files/files-init.c b/nss/nss_files/files-init.c
index 8aac3fb..a34c49a 100644
--- a/nss/nss_files/files-init.c
+++ b/nss/nss_files/files-init.c
@@ -18,6 +18,7 @@
 
 #ifdef USE_NSCD
 
+#include <string.h>
 #include <nscd/nscd.h>
 
 
@@ -30,7 +31,7 @@ static union							\
   {								\
     .file =							\
     {								\
-      .fname = filename, ## __VA_ARGS__				\
+      __VA_ARGS__						\
     }								\
   }
 
@@ -45,16 +46,22 @@ TF (netgr, "/etc/netgroup");
 void
 _nss_files_init (void (*cb) (size_t, struct traced_file *))
 {
+  strcpy (pwd_traced_file.file.fname, "/etc/passwd");
   cb (pwddb, &pwd_traced_file.file);
 
+  strcpy (grp_traced_file.file.fname, "/etc/group");
   cb (grpdb, &grp_traced_file.file);
 
+  strcpy (hst_traced_file.file.fname, "/etc/hosts");
   cb (hstdb, &hst_traced_file.file);
 
+  strcpy (resolv_traced_file.file.fname, "/etc/resolv.conf");
   cb (hstdb, &resolv_traced_file.file);
 
+  strcpy (serv_traced_file.file.fname, "/etc/services");
   cb (servdb, &serv_traced_file.file);
 
+  strcpy (netgr_traced_file.file.fname, "/etc/netgroup");
   cb (netgrdb, &netgr_traced_file.file);
 }
 
-- 
1.8.2.1

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]