From: Sami Kerola Date: Sat, 20 Dec 2014 12:23:06 +0000 (+0000) Subject: newgrp: simplify if else clauses X-Git-Tag: v2.26-rc1~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=477135dfec163b638b58cdb789949b0863a487a5;p=thirdparty%2Futil-linux.git newgrp: simplify if else clauses The 'if' clauses that have termination as either of the control flow results will never need 'else'. Making the termination to happen true flow is enough. Signed-off-by: Sami Kerola --- diff --git a/login-utils/newgrp.c b/login-utils/newgrp.c index 58c9078eb1..3f5c720286 100644 --- a/login-utils/newgrp.c +++ b/login-utils/newgrp.c @@ -214,15 +214,12 @@ int main(int argc, char *argv[]) if (errno) err(EXIT_FAILURE, _("no such group")); else - /* No group */ errx(EXIT_FAILURE, _("no such group")); - } else { - if (allow_setgid(pw_entry, gr_entry)) { - if (setgid(gr_entry->gr_gid) < 0) - err(EXIT_FAILURE, _("setgid failed")); - } else - errx(EXIT_FAILURE, _("permission denied")); } + if (!allow_setgid(pw_entry, gr_entry)) + errx(EXIT_FAILURE, _("permission denied")); + if (setgid(gr_entry->gr_gid) < 0) + err(EXIT_FAILURE, _("setgid failed")); } if (setuid(getuid()) < 0)