Fix compiling with gcc [4.2.1] after r287797 when MK_HESOID == no and
MK_NIS == no by converting `i` back to an int, and instead cast the loop comparison to `int` The loop comparison is iterating the len(ns_dtab)-1, because the last element is the sentinel tuple { NULL, NULL, NULL, }, so when both HESOID and NIS are off, len(ns_dtab)-1 == 1 - 1 == 0, and the loop is skipped because the expression is tautologically false While here, convert `(sizeof(x) / sizeof(x[0]))` to `nitems(x)` Tested with: clang 3.7.0, gcc 4.2.1, and gcc 4.9.4 [*] with MK_NIS={no,yes} and by running bash -lc 'id -u && id -g && id' * gcc 4.9.4 needs another patch in order for the compile to succeed with -Werror with lib/libc/gen/getgrent.c Reported by: jhibbits
This commit is contained in:
parent
ea36ade1d1
commit
3e973f9b6d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=289925
@ -1239,14 +1239,13 @@ compat_setgrent(void *retval, void *mdata, va_list ap)
|
||||
int rv, stayopen;
|
||||
|
||||
#define set_setent(x, y) do { \
|
||||
unsigned int i; \
|
||||
\
|
||||
for (i = 0; i < (sizeof(x)/sizeof(x[0])) - 1; i++) \
|
||||
int i; \
|
||||
for (i = 0; i < (int)(nitems(x) - 1); i++) \
|
||||
x[i].mdata = (void *)y; \
|
||||
} while (0)
|
||||
|
||||
rv = compat_getstate(&st);
|
||||
if (rv != 0)
|
||||
if (rv != 0)
|
||||
return (NS_UNAVAIL);
|
||||
switch ((enum constants)mdata) {
|
||||
case SETGRENT:
|
||||
@ -1309,9 +1308,8 @@ compat_group(void *retval, void *mdata, va_list ap)
|
||||
int rv, stayopen, *errnop;
|
||||
|
||||
#define set_lookup_type(x, y) do { \
|
||||
unsigned int i; \
|
||||
\
|
||||
for (i = 0; i < (sizeof(x)/sizeof(x[0])) - 1; i++) \
|
||||
int i; \
|
||||
for (i = 0; i < (int)(nitems(x) - 1); i++) \
|
||||
x[i].mdata = (void *)y; \
|
||||
} while (0)
|
||||
|
||||
|
@ -1607,10 +1607,9 @@ compat_redispatch(struct compat_state *st, enum nss_lookup_type how,
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
void *discard;
|
||||
int rv, e;
|
||||
unsigned int i;
|
||||
int e, i, rv;
|
||||
|
||||
for (i = 0; i < sizeof(dtab)/sizeof(dtab[0]) - 1; i++)
|
||||
for (i = 0; i < (int)(nitems(dtab) - 1); i++)
|
||||
dtab[i].mdata = (void *)lookup_how;
|
||||
more:
|
||||
pwd_init(pwd);
|
||||
@ -1703,9 +1702,8 @@ compat_setpwent(void *retval, void *mdata, va_list ap)
|
||||
int rv, stayopen;
|
||||
|
||||
#define set_setent(x, y) do { \
|
||||
unsigned int i; \
|
||||
\
|
||||
for (i = 0; i < (sizeof(x)/sizeof(x[0])) - 1; i++) \
|
||||
int i; \
|
||||
for (i = 0; i < (int)(nitems(x) - 1); i++) \
|
||||
x[i].mdata = (void *)y; \
|
||||
} while (0)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user