* lib/shadow.c: Use SHADOW_SP_FLAG_UNSET for the initial

value of spwd.sp_flag.
	* lib/shadow.c: Add brackets.
	* lib/shadow.c: Avoid implicit conversion of pointers to
	booleans.
	* lib/shadow.c: The size argument of fgets is an int, not a
	size_t.
This commit is contained in:
nekral-guest 2008-06-13 21:55:51 +00:00
parent d65354efcf
commit afafd0f683
2 changed files with 28 additions and 12 deletions

View File

@ -1,3 +1,13 @@
2008-06-13 Nicolas François <nicolas.francois@centraliens.net>
* lib/shadow.c: Use SHADOW_SP_FLAG_UNSET for the initial
value of spwd.sp_flag.
* lib/shadow.c: Add brackets.
* lib/shadow.c: Avoid implicit conversion of pointers to
booleans.
* lib/shadow.c: The size argument of fgets is an int, not a
size_t.
2008-06-13 Nicolas François <nicolas.francois@centraliens.net> 2008-06-13 Nicolas François <nicolas.francois@centraliens.net>
* lib/commonio.c: len should be typed ssize_t as it is the return * lib/commonio.c: len should be typed ssize_t as it is the return

View File

@ -236,7 +236,7 @@ static struct spwd *my_sgetspent (const char *string)
if (i == OFIELDS) { if (i == OFIELDS) {
spwd.sp_warn = spwd.sp_inact = spwd.sp_expire = spwd.sp_warn = spwd.sp_inact = spwd.sp_expire =
spwd.sp_flag = -1; spwd.sp_flag = SHADOW_SP_FLAG_UNSET;
return &spwd; return &spwd;
} }
@ -291,8 +291,9 @@ static struct spwd *my_sgetspent (const char *string)
#else #else
return 0; return 0;
#endif #endif
} else if (fields[7][0] == '\0') } else if (fields[7][0] == '\0') {
spwd.sp_expire = -1; spwd.sp_expire = -1;
}
/* /*
* This field is reserved for future use. But it isn't supposed * This field is reserved for future use. But it isn't supposed
@ -302,15 +303,17 @@ static struct spwd *my_sgetspent (const char *string)
spwd.sp_flag = strtol (fields[8], &cpp, 10); spwd.sp_flag = strtol (fields[8], &cpp, 10);
if ((spwd.sp_flag == 0) && *cpp) { if ((spwd.sp_flag == 0) && *cpp) {
#ifdef USE_NIS #ifdef USE_NIS
if (!nis_used) if (!nis_used) {
return 0; return 0;
else } else {
spwd.sp_flag = -1; spwd.sp_flag = SHADOW_SP_FLAG_UNSET;
}
#else #else
return 0; return 0;
#endif #endif
} else if (fields[8][0] == '\0') } else if (fields[8][0] == '\0') {
spwd.sp_flag = -1; spwd.sp_flag = SHADOW_SP_FLAG_UNSET;
}
return (&spwd); return (&spwd);
} }
@ -324,21 +327,24 @@ struct spwd *fgetspent (FILE * fp)
char buf[BUFSIZ]; char buf[BUFSIZ];
char *cp; char *cp;
if (!fp) if (NULL == fp) {
return (0); return (0);
}
#ifdef USE_NIS #ifdef USE_NIS
while (fgets (buf, sizeof buf, fp) != (char *) 0) while (fgets (buf, (int) sizeof buf, fp) != (char *) 0)
#else #else
if (fgets (buf, sizeof buf, fp) != (char *) 0) if (fgets (buf, (int) sizeof buf, fp) != (char *) 0)
#endif #endif
{ {
cp = strchr (buf, '\n'); cp = strchr (buf, '\n');
if (NULL != cp) if (NULL != cp) {
*cp = '\0'; *cp = '\0';
}
#ifdef USE_NIS #ifdef USE_NIS
if (nis_ignore && IS_NISCHAR (buf[0])) if (nis_ignore && IS_NISCHAR (buf[0])) {
continue; continue;
}
#endif #endif
return my_sgetspent (buf); return my_sgetspent (buf);
} }