From: Alejandro Colomar Date: Tue, 9 Jan 2024 19:09:58 +0000 (+0100) Subject: lib/shadow.c: my_sgetspent(): Merge 'else {if}' into 'else if' X-Git-Tag: 4.17.0-rc1~158 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9cc053df74bbdc67e026116b1ff2be271dbf9e7;p=thirdparty%2Fshadow.git lib/shadow.c: my_sgetspent(): Merge 'else {if}' into 'else if' This reduces indentation. Reviewed-by: "Serge E. Hallyn" Signed-off-by: Alejandro Colomar --- diff --git a/lib/shadow.c b/lib/shadow.c index cb6c726ed..8c1fc8a5e 100644 --- a/lib/shadow.c +++ b/lib/shadow.c @@ -108,40 +108,34 @@ static struct spwd *my_sgetspent (const char *string) * incorrectly formatted number, unless we are using NIS. */ - if (fields[2][0] == '\0') { + if (fields[2][0] == '\0') spwd.sp_lstchg = -1; - } else { - if (str2sl(&spwd.sp_lstchg, fields[2]) == -1) - return 0; - if (spwd.sp_lstchg < 0) - return 0; - } + else if (str2sl(&spwd.sp_lstchg, fields[2]) == -1) + return 0; + else if (spwd.sp_lstchg < 0) + return 0; /* * Get the minimum period between password changes. */ - if (fields[3][0] == '\0') { + if (fields[3][0] == '\0') spwd.sp_min = -1; - } else { - if (str2sl(&spwd.sp_min, fields[3]) == -1) - return 0; - if (spwd.sp_min < 0) - return 0; - } + else if (str2sl(&spwd.sp_min, fields[3]) == -1) + return 0; + else if (spwd.sp_min < 0) + return 0; /* * Get the maximum number of days a password is valid. */ - if (fields[4][0] == '\0') { + if (fields[4][0] == '\0') spwd.sp_max = -1; - } else { - if (str2sl(&spwd.sp_max, fields[4]) == -1) - return 0; - if (spwd.sp_max < 0) - return 0; - } + else if (str2sl(&spwd.sp_max, fields[4]) == -1) + return 0; + else if (spwd.sp_max < 0) + return 0; /* * If there are only OFIELDS fields (this is a SVR3.2 /etc/shadow @@ -161,56 +155,48 @@ static struct spwd *my_sgetspent (const char *string) * Get the number of days of password expiry warning. */ - if (fields[5][0] == '\0') { + if (fields[5][0] == '\0') spwd.sp_warn = -1; - } else { - if (str2sl(&spwd.sp_warn, fields[5]) == -1) - return 0; - if (spwd.sp_warn < 0) - return 0; - } + else if (str2sl(&spwd.sp_warn, fields[5]) == -1) + return 0; + else if (spwd.sp_warn < 0) + return 0; /* * Get the number of days of inactivity before an account is * disabled. */ - if (fields[6][0] == '\0') { + if (fields[6][0] == '\0') spwd.sp_inact = -1; - } else { - if (str2sl(&spwd.sp_inact, fields[6]) == -1) - return 0; - if (spwd.sp_inact < 0) - return 0; - } + else if (str2sl(&spwd.sp_inact, fields[6]) == -1) + return 0; + else if (spwd.sp_inact < 0) + return 0; /* * Get the number of days after the epoch before the account is * set to expire. */ - if (fields[7][0] == '\0') { + if (fields[7][0] == '\0') spwd.sp_expire = -1; - } else { - if (str2sl(&spwd.sp_expire, fields[7]) == -1) - return 0; - if (spwd.sp_expire < 0) - return 0; - } + else if (str2sl(&spwd.sp_expire, fields[7]) == -1) + return 0; + else if (spwd.sp_expire < 0) + return 0; /* * This field is reserved for future use. But it isn't supposed * to have anything other than a valid integer in it. */ - if (fields[8][0] == '\0') { + if (fields[8][0] == '\0') spwd.sp_flag = SHADOW_SP_FLAG_UNSET; - } else { - if (str2ul(&spwd.sp_flag, fields[8]) == -1) - return 0; - if (spwd.sp_flag < 0) - return 0; - } + else if (str2ul(&spwd.sp_flag, fields[8]) == -1) + return 0; + else if (spwd.sp_flag < 0) + return 0; return (&spwd); }