retval(1): fix style
This commit is contained in:
parent
df1b0a2d9d
commit
4a405fdfbb
@ -3,22 +3,22 @@
|
|||||||
#include <stdlib.h> /* strtol(3) */
|
#include <stdlib.h> /* strtol(3) */
|
||||||
#include <sysexits.h> /* EX_USAGE */
|
#include <sysexits.h> /* EX_USAGE */
|
||||||
|
|
||||||
int usage(char *s){
|
char *program_name = "retval";
|
||||||
fprintf(stderr, "Usage: %s [status]\n", s == NULL ? "retval" : s);
|
|
||||||
return EX_USAGE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]){
|
int main(int argc, char *argv[]){
|
||||||
|
|
||||||
switch(argc){
|
switch(argc){
|
||||||
case 2: { unsigned int s;
|
case 2: {
|
||||||
|
unsigned int s;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
s = strtol(argv[1], &argv[1], 10);
|
s = strtol(argv[1], &argv[1], 10);
|
||||||
if(*argv[1] != '\0' || errno != 0){
|
|
||||||
return usage(argv[0]);
|
if(*argv[1] == '\0' && errno == 0) { return s; }
|
||||||
}
|
} /* FALLTHROUGH */
|
||||||
return s;
|
default:
|
||||||
}
|
fprintf(stderr, "Usage: %s status\n",
|
||||||
default: return usage(argv[0]);
|
argv[0] == NULL ? program_name : argv[0]);
|
||||||
|
return EX_USAGE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user