]> granicus.if.org Git - shadow/commitdiff
* libmisc/isexpired.c: ARGSUSED is no more needed (shadow is always supported).
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Mon, 26 May 2008 00:14:10 +0000 (00:14 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Mon, 26 May 2008 00:14:10 +0000 (00:14 +0000)
* libmisc/isexpired.c: Avoid implicit conversion of pointers to booleans.
* libmisc/isexpired.c: Add brackets and parenthesis.

ChangeLog
libmisc/isexpired.c

index d5236148637d3a3028c08ee5e1a7b84a593b453d..90ec8ba8f16aa1d2fce574f04ab8d37459fbfe48 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-05-26  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * libmisc/isexpired.c: ARGSUSED is no more needed (shadow is
+       always supported).
+       * libmisc/isexpired.c: Avoid implicit conversion of pointers to
+       booleans.
+       * libmisc/isexpired.c: Add brackets and parenthesis.
+
 2008-05-26  Nicolas François  <nicolas.francois@centraliens.net>
 
        * libmisc/sulog.c (sulog): The success argument is a bool.
index 7d295c8c6d055525b8b41084fe37ad14084e34e2..b89a1af184487469cc30da4873d7709d810c4759 100644 (file)
@@ -2,6 +2,7 @@
  * Copyright (c) 1989 - 1994, Julianne Frances Haugh
  * Copyright (c) 1996 - 1997, Marek Michałkiewicz
  * Copyright (c) 2001 - 2005, Tomasz Kłoczko
+ * Copyright (c) 2008       , Nicolas François
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  *     isexpired calculates the expiration date based on the
  *     password expiration criteria.
  */
- /*ARGSUSED*/ int isexpired (const struct passwd *pw, const struct spwd *sp)
+int isexpired (const struct passwd *pw, const struct spwd *sp)
 {
        long now;
 
        now = time ((time_t *) 0) / SCALE;
 
-       if (!sp)
+       if (NULL == sp) {
                sp = pwd_to_spwd (pw);
+       }
 
        /*
         * Quick and easy - there is an expired account field
         * 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))
+       if ((sp->sp_lstchg == 0) &&
+           (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)
+           now >= (sp->sp_lstchg + sp->sp_max + sp->sp_inact))
                return 2;
 
        /*
         * the password has expired.
         */
 
-       if (now >= sp->sp_lstchg + sp->sp_max)
+       if (now >= (sp->sp_lstchg + sp->sp_max))
                return 1;
        return 0;
 }
+