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] Fix nss/nss_test1.c compile with latest GCC


While building and testing glibc with the latest (ToT) GCC, I got the
following error message:

nss_test1.c:60:46: error: division â??sizeof (struct passwd *) / sizeof (struct passwd)â?? does not compute the number of array elements [-Werror=sizeof-pointer-div]
 #define default_npwd_data (sizeof (pwd_data) / sizeof (pwd_data[0]))

I think this is due to new error checking added to GCC and in this
case I think that GCC is correct in its error.  We should
be using the default_pwd_data in this expression and not pwd_data.

This patch fixes the proglem, OK for checkin?


2017-07-19  Steve Ellcey  <sellcey@cavium.com>

	* nss/nss_test1.c (default_npwd_data): Fix definition.



diff --git a/nss/nss_test1.c b/nss/nss_test1.c
index b728e41..86bbc2c 100644
--- a/nss/nss_test1.c
+++ b/nss/nss_test1.c
@@ -57,7 +57,8 @@ static struct passwd default_pwd_data[] =
     PWD (60),
     PWD (20000)
   };
-#define default_npwd_data (sizeof (pwd_data) / sizeof (pwd_data[0]))
+#define default_npwd_data \
+  (sizeof (default_pwd_data) / sizeof (default_pwd_data[0]))
 
 static struct passwd *pwd_data = default_pwd_data;
 static int npwd_data = default_npwd_data;


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