From: Alejandro Colomar Date: Thu, 18 Jan 2024 10:15:17 +0000 (+0100) Subject: src/sulogin.c: Invert logic to reduce indentation X-Git-Tag: 4.15.1~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88760598f079f945fc7b6c72786e3101fd4f45b1;p=thirdparty%2Fshadow.git src/sulogin.c: Invert logic to reduce indentation Also, it was checking for >=0 for success, but since that code is for opening a different tty as stdin, that was bogus. But since it's guaranteed to be either 0 or -1, this commit doesn't add any code to make sure it's 0 (i.e., we could say !=0 instead of ==-1). That's more appropriate for a different commit. Signed-off-by: Alejandro Colomar --- diff --git a/src/sulogin.c b/src/sulogin.c index 244a2acdf..209717432 100644 --- a/src/sulogin.c +++ b/src/sulogin.c @@ -84,12 +84,10 @@ main(int argc, char *argv[]) close(1); close(2); - if (open(argv[1], O_RDWR) >= 0) { - dup (0); - dup (0); - } else { - exit (1); - } + if (open(argv[1], O_RDWR) == -1) + exit(1); + dup(0); + dup(0); } if (access (PASSWD_FILE, F_OK) == -1) { /* must be a password file! */ (void) puts (_("No password file"));