* libmisc/valid.c: Avoid implicit conversion of pointers /chars to booleans.

* libmisc/valid.c: Add brackets.
This commit is contained in:
nekral-guest 2008-05-25 23:22:15 +00:00
parent f14452ec3c
commit 1ebf7842f5
2 changed files with 14 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2008-05-26 Nicolas François <nicolas.francois@centraliens.net>
* libmisc/valid.c: Avoid implicit conversion of pointers /chars to
booleans.
* libmisc/valid.c: Add brackets.
2008-05-26 Nicolas François <nicolas.francois@centraliens.net> 2008-05-26 Nicolas François <nicolas.francois@centraliens.net>
* libmisc/yesno.c: yes_or_no returns a bool instead of int. * libmisc/yesno.c: yes_or_no returns a bool instead of int.

View File

@ -61,11 +61,12 @@ int valid (const char *password, const struct passwd *ent)
* routine is meant to waste CPU time. * routine is meant to waste CPU time.
*/ */
if (ent->pw_name && !ent->pw_passwd[0]) { if ((NULL != ent->pw_name) && ('\0' == ent->pw_passwd[0])) {
if (!password[0]) if ('\0' == password[0]) {
return (1); /* user entered nothing */ return (1); /* user entered nothing */
else } else {
return (0); /* user entered something! */ return (0); /* user entered something! */
}
} }
/* /*
@ -93,9 +94,11 @@ int valid (const char *password, const struct passwd *ent)
* cause non-existent users to not be validated. * cause non-existent users to not be validated.
*/ */
if (ent->pw_name && strcmp (encrypted, ent->pw_passwd) == 0) if ((NULL != ent->pw_name) &&
(strcmp (encrypted, ent->pw_passwd) == 0)) {
return (1); return (1);
else } else {
return (0); return (0);
}
} }