From: nekral-guest Date: Mon, 26 May 2008 00:14:10 +0000 (+0000) Subject: * libmisc/isexpired.c: ARGSUSED is no more needed (shadow is always supported). X-Git-Tag: 4.1.3~472 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fc6d8e933b385a75ec055e562b7238ffdd83de8a;p=shadow * 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. --- diff --git a/ChangeLog b/ChangeLog index d5236148..90ec8ba8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-05-26 Nicolas François + + * 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 * libmisc/sulog.c (sulog): The success argument is a bool. diff --git a/libmisc/isexpired.c b/libmisc/isexpired.c index 7d295c8c..b89a1af1 100644 --- a/libmisc/isexpired.c +++ b/libmisc/isexpired.c @@ -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 @@ -51,14 +52,15 @@ * 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 @@ -77,11 +79,13 @@ * 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; /* @@ -100,7 +104,8 @@ * the password has expired. */ - if (now >= sp->sp_lstchg + sp->sp_max) + if (now >= (sp->sp_lstchg + sp->sp_max)) return 1; return 0; } +