From 4a405fdfbb3312157a01e4c070229304e68d299f Mon Sep 17 00:00:00 2001 From: DTB Date: Tue, 23 Jul 2024 17:47:37 -0600 Subject: [PATCH] retval(1): fix style --- retval/retval.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/retval/retval.c b/retval/retval.c index 6baca45..cfd6121 100644 --- a/retval/retval.c +++ b/retval/retval.c @@ -3,22 +3,22 @@ #include /* strtol(3) */ #include /* EX_USAGE */ -int usage(char *s){ - fprintf(stderr, "Usage: %s [status]\n", s == NULL ? "retval" : s); - return EX_USAGE; -} +char *program_name = "retval"; int main(int argc, char *argv[]){ switch(argc){ - case 2: { unsigned int s; - errno = 0; - s = strtol(argv[1], &argv[1], 10); - if(*argv[1] != '\0' || errno != 0){ - return usage(argv[0]); - } - return s; - } - default: return usage(argv[0]); + case 2: { + unsigned int s; + + errno = 0; + s = strtol(argv[1], &argv[1], 10); + + if(*argv[1] == '\0' && errno == 0) { return s; } + } /* FALLTHROUGH */ + default: + fprintf(stderr, "Usage: %s status\n", + argv[0] == NULL ? program_name : argv[0]); + return EX_USAGE; } }