]> granicus.if.org Git - shadow/commitdiff
* libmisc/isexpired.c: Cast number of days to a long integer.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 13 Jun 2008 20:12:03 +0000 (20:12 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 13 Jun 2008 20:12:03 +0000 (20:12 +0000)
* libmisc/isexpired.c: Add brackets and parenthesis.

ChangeLog
libmisc/isexpired.c

index 3ef6ad794cf65368cea47d5b948146f70bd22a5a..d36192002774c528705afe44cd65a3f1bde46e17 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-06-13  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * libmisc/isexpired.c: Cast number of days to a long integer.
+       * libmisc/isexpired.c: Add brackets and parenthesis.
+
 2008-06-13  Nicolas François  <nicolas.francois@centraliens.net>
 
        * libmisc/copydir.c: Do not specify a size of arrays in the
index b89a1af184487469cc30da4873d7709d810c4759..e93c9d49b2498e71ce9f0ed2a2e7b54911f4b658 100644 (file)
@@ -56,7 +56,7 @@ int isexpired (const struct passwd *pw, const struct spwd *sp)
 {
        long now;
 
-       now = time ((time_t *) 0) / SCALE;
+       now = (long) time ((time_t *) 0) / SCALE;
 
        if (NULL == sp) {
                sp = pwd_to_spwd (pw);
@@ -68,8 +68,9 @@ int isexpired (const struct passwd *pw, const struct spwd *sp)
         * one first since it is worse.
         */
 
-       if (sp->sp_expire > 0 && now >= sp->sp_expire)
+       if ((sp->sp_expire > 0) && (now >= sp->sp_expire)) {
                return 3;
+       }
 
        /*
         * Last changed date 1970-01-01 (not very likely) means that
@@ -79,14 +80,17 @@ int isexpired (const struct passwd *pw, const struct spwd *sp)
         * if /etc/shadow doesn't exist, getspnam() still succeeds and
         * returns sp_lstchg==0 (must change password) instead of -1!
         */
-       if ((sp->sp_lstchg == 0) &&
-           (strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING) == 0)) {
+       if (   (0 == sp->sp_lstchg)
+           && (strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING) == 0)) {
                return 1;
        }
 
-       if (sp->sp_lstchg > 0 && sp->sp_max >= 0 && sp->sp_inact >= 0 &&
-           now >= (sp->sp_lstchg + sp->sp_max + sp->sp_inact))
+       if (   (sp->sp_lstchg > 0)
+           && (sp->sp_max >= 0)
+           && (sp->sp_inact >= 0)
+           && (now >= (sp->sp_lstchg + sp->sp_max + sp->sp_inact))) {
                return 2;
+       }
 
        /*
         * The last and max fields must be present for an account
@@ -94,9 +98,11 @@ int isexpired (const struct passwd *pw, const struct spwd *sp)
         * is considered to be infinite.
         */
 
-       if (sp->sp_lstchg == -1 ||
-           sp->sp_max == -1 || sp->sp_max >= (10000L * DAY / SCALE))
+       if (   (-1 == sp->sp_lstchg)
+           || (-1 == sp->sp_max)
+           || (sp->sp_max >= (10000L * DAY / SCALE))) {
                return 0;
+       }
 
        /*
         * Calculate today's day and the day on which the password
@@ -104,8 +110,9 @@ int isexpired (const struct passwd *pw, const struct spwd *sp)
         * the password has expired.
         */
 
-       if (now >= (sp->sp_lstchg + sp->sp_max))
+       if (now >= (sp->sp_lstchg + sp->sp_max)) {
                return 1;
+       }
        return 0;
 }