* lib/sgetgrent.c: implicit conversion of pointers / chars to booleans.

* lib/sgetgrent.c: Avoid assignments in comparisons.
	* lib/sgetgrent.c: Add brackets.
This commit is contained in:
nekral-guest 2008-05-26 08:31:14 +00:00
parent 6ce26e12f5
commit 6f88bcf581
2 changed files with 25 additions and 8 deletions

View File

@ -1,3 +1,10 @@
2008-05-26 Nicolas François <nicolas.francois@centraliens.net>
* lib/sgetgrent.c: implicit conversion of pointers / chars to
booleans.
* lib/sgetgrent.c: Avoid assignments in comparisons.
* lib/sgetgrent.c: Add brackets.
2008-05-26 Nicolas François <nicolas.francois@centraliens.net>
* lib/encrypt.c: Avoid implicit conversion of pointers to

View File

@ -87,10 +87,12 @@ static char **list (char *s)
if (!s || s[0] == '\0')
break;
members[i++] = s;
while (*s && *s != ',')
while (('\0' != *s) && (',' != *s)) {
s++;
if (*s)
}
if ('\0' != *s) {
*s++ = '\0';
}
}
members[i] = (char *) 0;
return members;
@ -120,22 +122,30 @@ struct group *sgetgrent (const char *buf)
}
strcpy (grpbuf, buf);
if ((cp = strrchr (grpbuf, '\n')))
cp = strrchr (grpbuf, '\n');
if (NULL != cp) {
*cp = '\0';
}
for (cp = grpbuf, i = 0; i < NFIELDS && cp; i++) {
grpfields[i] = cp;
if ((cp = strchr (cp, ':')))
*cp++ = 0;
cp = strchr (cp, ':');
if (NULL != cp) {
*cp = '\0';
cp++;
}
}
if (i < (NFIELDS - 1) || *grpfields[2] == '\0') {
return (struct group *) 0;
}
if (i < (NFIELDS - 1) || *grpfields[2] == '\0')
return 0;
grent.gr_name = grpfields[0];
grent.gr_passwd = grpfields[1];
grent.gr_gid = atoi (grpfields[2]);
grent.gr_mem = list (grpfields[3]);
if (!grent.gr_mem)
if (NULL == grent.gr_mem) {
return (struct group *) 0; /* out of memory */
}
return &grent;
}