From 9d325068a8deee98493dd44eb62a3b66b4951462 Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Sat, 9 Sep 2017 22:08:43 +0100 Subject: [PATCH] test/getfullname.c: Move return case first in if-else chain. --- test/getfullname.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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. -- 2.56.0