This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[Patch] Fix nss/nss_test1.c compile with latest GCC
- From: Steve Ellcey <sellcey at cavium dot com>
- To: libc-alpha at sourceware dot org
- Date: Wed, 19 Jul 2017 14:17:09 -0700
- Subject: [Patch] Fix nss/nss_test1.c compile with latest GCC
- Authentication-results: sourceware.org; auth=none
- Reply-to: sellcey at cavium dot com
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;