From: Ralph Corderoy Date: Sat, 9 Sep 2017 21:08:43 +0000 (+0100) Subject: test/getfullname.c: Move return case first in if-else chain. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/9d325068a8deee98493dd44eb62a3b66b4951462?ds=inline;hp=3b6170b27ba8fedbb4d67d2842bfaa38d4417962 test/getfullname.c: Move return case first in if-else chain. --- diff --git a/test/getfullname.c b/test/getfullname.c index 0e12fe93..89a54910 100644 --- a/test/getfullname.c +++ b/test/getfullname.c @@ -22,9 +22,12 @@ main(int argc, char *argv[]) struct passwd *pwd; char buf[BUFSIZ], *p; + if (argc > 2) { + fprintf (stderr, "usage: %s [name]\n", argv[0]); + return 1; + } if (argc < 2) { pwd = getpwuid(getuid()); - if (! pwd) { fprintf(stderr, "Unable to retrieve user info for " "userid %ld\n", (long) getuid()); @@ -33,12 +36,8 @@ main(int argc, char *argv[]) strncpy(buf, pwd->pw_gecos, sizeof(buf)); buf[sizeof(buf) - 1] = '\0'; - } else if (argc == 2) { + } else strncpy(buf, argv[1], sizeof(buf)); - } else if (argc > 2) { - fprintf (stderr, "usage: %s [name]\n", argv[0]); - return 1; - } /* * Perform the same processing that getuserinfo() does.