From 94b3b9819691331b58566327b4c75121939af917 Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Tue, 1 Jan 2008 23:07:55 +0000 Subject: [PATCH] Avoid assignments in conditionals. --- ChangeLog | 4 ++++ src/newgrp.c | 15 ++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2bb49d91..2165f424 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-01-01 Nicolas François + + * src/newgrp.c: Avoid assignments in conditionals. + 2008-01-01 Nicolas François * lib/shadow.c: Avoid assignments in conditionals. diff --git a/src/newgrp.c b/src/newgrp.c index 089bb2f2..065567dd 100644 --- a/src/newgrp.c +++ b/src/newgrp.c @@ -240,7 +240,8 @@ int main (int argc, char **argv) * Perhaps in the past, but the default behavior now depends on the * group entry, so it had better exist. -- JWP */ - if (!(grp = xgetgrgid (pwd->pw_gid))) { + grp = xgetgrgid (pwd->pw_gid); + if (NULL == grp) { fprintf (stderr, _("unknown GID: %lu\n"), (unsigned long) pwd->pw_gid); SYSLOG ((LOG_CRIT, "unknown GID: %lu", @@ -319,7 +320,8 @@ int main (int argc, char **argv) * including the user's name in the member list of the user's login * group. -- JWP */ - if (!(grp = getgrnam (group))) { /* local, no need for xgetgrnam */ + grp = getgrnam (group); /* local, no need for xgetgrnam */ + if (NULL == grp) { fprintf (stderr, _("unknown group: %s\n"), group); goto failure; } @@ -341,7 +343,8 @@ int main (int argc, char **argv) grp = xgetgrnam (group); } #ifdef SHADOWGRP - if ((sgrp = getsgnam (group))) { + sgrp = getsgnam (group); + if (NULL != sgrp) { grp->gr_passwd = sgrp->sg_passwd; grp->gr_mem = sgrp->sg_mem; } @@ -364,7 +367,8 @@ int main (int argc, char **argv) * password, and the group has a password, she needs to give the * group password. */ - if ((spwd = xgetspnam (name))) + spwd = xgetspnam (name); + if (NULL != spwd) pwd->pw_passwd = spwd->sp_pwdp; if (pwd->pw_passwd[0] == '\0' && grp->gr_passwd[0]) @@ -381,7 +385,8 @@ int main (int argc, char **argv) * get the password from her, and set the salt for * the decryption from the group file. */ - if (!(cp = getpass (_("Password: ")))) + cp = getpass (_("Password: ")); + if (NULL == cp) goto failure; /*