Fix nss/nss_test1.c compile with latest GCC

Message ID 201707192117.v6JLH93S004005@sellcey-dt.caveonetworks.com
State Committed
Headers

Commit Message

Steve Ellcey July 19, 2017, 9:17 p.m. UTC
  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.
  

Patch

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;