Avoid assignments in comparisons.
This commit is contained in:
parent
37ccc0a3d4
commit
3c890a55d8
@ -10,6 +10,7 @@
|
|||||||
information to the audit_logger.
|
information to the audit_logger.
|
||||||
* src/chage.c: Avoid implicit brackets.
|
* src/chage.c: Avoid implicit brackets.
|
||||||
* src/chage.c: Avoid implicit conversion to booleans.
|
* src/chage.c: Avoid implicit conversion to booleans.
|
||||||
|
* src/chage.c: Avoid assignments in comparisons.
|
||||||
|
|
||||||
2007-12-28 Nicolas François <nicolas.francois@centraliens.net>
|
2007-12-28 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
25
src/chage.c
25
src/chage.c
@ -157,14 +157,16 @@ static int new_fields (void)
|
|||||||
|
|
||||||
snprintf (buf, sizeof buf, "%ld", mindays);
|
snprintf (buf, sizeof buf, "%ld", mindays);
|
||||||
change_field (buf, sizeof buf, _("Minimum Password Age"));
|
change_field (buf, sizeof buf, _("Minimum Password Age"));
|
||||||
if (((mindays = strtol (buf, &cp, 10)) == 0 && ('\0' != *cp))
|
mindays = strtol (buf, &cp, 10);
|
||||||
|
if ( ((mindays == 0) && ('\0' != *cp))
|
||||||
|| (mindays < -1)) {
|
|| (mindays < -1)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf (buf, sizeof buf, "%ld", maxdays);
|
snprintf (buf, sizeof buf, "%ld", maxdays);
|
||||||
change_field (buf, sizeof buf, _("Maximum Password Age"));
|
change_field (buf, sizeof buf, _("Maximum Password Age"));
|
||||||
if (((maxdays = strtol (buf, &cp, 10)) == 0 && ('\0' != *cp))
|
maxdays = strtol (buf, &cp, 10);
|
||||||
|
if ( ((maxdays == 0) && ('\0' != *cp))
|
||||||
|| (maxdays < -1)) {
|
|| (maxdays < -1)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -175,20 +177,25 @@ static int new_fields (void)
|
|||||||
|
|
||||||
if (strcmp (buf, EPOCH) == 0) {
|
if (strcmp (buf, EPOCH) == 0) {
|
||||||
lastday = -1;
|
lastday = -1;
|
||||||
} else if ((lastday = strtoday (buf)) == -1) {
|
} else {
|
||||||
|
lastday = strtoday (buf);
|
||||||
|
if (lastday == -1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
snprintf (buf, sizeof buf, "%ld", warndays);
|
snprintf (buf, sizeof buf, "%ld", warndays);
|
||||||
change_field (buf, sizeof buf, _("Password Expiration Warning"));
|
change_field (buf, sizeof buf, _("Password Expiration Warning"));
|
||||||
if (((warndays = strtol (buf, &cp, 10)) == 0 && ('\0' != *cp))
|
warndays = strtol (buf, &cp, 10);
|
||||||
|
if ( ((warndays == 0) && ('\0' != *cp))
|
||||||
|| (warndays < -1)) {
|
|| (warndays < -1)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf (buf, sizeof buf, "%ld", inactdays);
|
snprintf (buf, sizeof buf, "%ld", inactdays);
|
||||||
change_field (buf, sizeof buf, _("Password Inactive"));
|
change_field (buf, sizeof buf, _("Password Inactive"));
|
||||||
if (((inactdays = strtol (buf, &cp, 10)) == 0 && ('\0' != *cp))
|
inactdays = strtol (buf, &cp, 10);
|
||||||
|
if ( ((inactdays == 0) && ('\0' != *cp))
|
||||||
|| (inactdays < -1)) {
|
|| (inactdays < -1)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -200,9 +207,12 @@ static int new_fields (void)
|
|||||||
|
|
||||||
if (strcmp (buf, EPOCH) == 0) {
|
if (strcmp (buf, EPOCH) == 0) {
|
||||||
expdays = -1;
|
expdays = -1;
|
||||||
} else if ((expdays = strtoday (buf)) == -1) {
|
} else {
|
||||||
|
expdays = strtoday (buf);
|
||||||
|
if (expdays == -1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -606,7 +616,8 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
open_files (lflg);
|
open_files (lflg);
|
||||||
|
|
||||||
if (!(pw = pw_locate (argv[optind]))) {
|
pw = pw_locate (argv[optind]);
|
||||||
|
if (NULL == pw) {
|
||||||
fprintf (stderr, _("%s: unknown user %s\n"), Prog,
|
fprintf (stderr, _("%s: unknown user %s\n"), Prog,
|
||||||
argv[optind]);
|
argv[optind]);
|
||||||
closelog ();
|
closelog ();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user