diff options
author | Ruediger Meier | 2017-06-19 20:52:50 +0200 |
---|---|---|
committer | Ruediger Meier | 2017-06-26 14:38:24 +0200 |
commit | 6e1eda6f229f87b77471ce6eb7cbf0ede7c8029e (patch) | |
tree | 5e74a0cd99493e934780db2b434c75e995a6bd17 /misc-utils | |
parent | misc: never use usage(ERROR) (diff) | |
download | kernel-qcow2-util-linux-6e1eda6f229f87b77471ce6eb7cbf0ede7c8029e.tar.gz kernel-qcow2-util-linux-6e1eda6f229f87b77471ce6eb7cbf0ede7c8029e.tar.xz kernel-qcow2-util-linux-6e1eda6f229f87b77471ce6eb7cbf0ede7c8029e.zip |
misc: never use usage(stderr)
Here we fix all cases where we have usage(FILE*)
functions.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Diffstat (limited to 'misc-utils')
-rw-r--r-- | misc-utils/cal.c | 12 | ||||
-rw-r--r-- | misc-utils/look.c | 12 | ||||
-rw-r--r-- | misc-utils/rename.c | 9 | ||||
-rw-r--r-- | misc-utils/wipefs.c | 14 |
4 files changed, 28 insertions, 19 deletions
diff --git a/misc-utils/cal.c b/misc-utils/cal.c index 86e159bfa..f73cbbf30 100644 --- a/misc-utils/cal.c +++ b/misc-utils/cal.c @@ -244,7 +244,7 @@ static int week_number(int day, int month, int32_t year, const struct cal_contro static int week_to_day(const struct cal_control *ctl); static int center_str(const char *src, char *dest, size_t dest_size, size_t width); static void center(const char *str, size_t len, int separate); -static void __attribute__((__noreturn__)) usage(FILE *out); +static void __attribute__((__noreturn__)) usage(void); int main(int argc, char **argv) { @@ -394,7 +394,7 @@ int main(int argc, char **argv) printf(UTIL_LINUX_VERSION); return EXIT_SUCCESS; case 'h': - usage(stdout); + usage(); default: errtryhelp(EXIT_FAILURE); } @@ -470,7 +470,8 @@ int main(int argc, char **argv) ctl.req.month = local_time->tm_mon + 1; break; default: - usage(stderr); + warnx(_("bad usage")); + errtryhelp(EXIT_FAILURE); } if (0 < ctl.req.week) { @@ -987,8 +988,9 @@ static void center(const char *str, size_t len, int separate) } } -static void __attribute__ ((__noreturn__)) usage(FILE * out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] [[[day] month] year]\n"), program_invocation_short_name); fprintf(out, _(" %s [options] <timestamp|monthname>\n"), program_invocation_short_name); @@ -1017,5 +1019,5 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out) fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("cal(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } diff --git a/misc-utils/look.c b/misc-utils/look.c index 3f785a727..a0d898db1 100644 --- a/misc-utils/look.c +++ b/misc-utils/look.c @@ -78,7 +78,7 @@ static int compare (char *, char *); static char *linear_search (char *, char *); static int look (char *, char *); static void print_from (char *, char *); -static void __attribute__ ((__noreturn__)) usage(FILE * out); +static void __attribute__((__noreturn__)) usage(void); int main(int argc, char *argv[]) @@ -126,7 +126,7 @@ main(int argc, char *argv[]) printf(UTIL_LINUX_VERSION); return EXIT_SUCCESS; case 'h': - usage(stdout); + usage(); default: errtryhelp(EXIT_FAILURE); } @@ -143,7 +143,8 @@ main(int argc, char *argv[]) string = *argv; break; default: - usage(stderr); + warnx(_("bad usage")); + errtryhelp(EXIT_FAILURE); } if (termchar != '\0' && (p = strchr(string, termchar)) != NULL) @@ -348,8 +349,9 @@ compare(char *s2, char *s2end) { return ((i > 0) ? LESS : (i < 0) ? GREATER : EQUAL); } -static void __attribute__ ((__noreturn__)) usage(FILE * out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] <string> [<file>...]\n"), program_invocation_short_name); @@ -367,5 +369,5 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out) fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("look(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } diff --git a/misc-utils/rename.c b/misc-utils/rename.c index 8230ac3da..48606d75e 100644 --- a/misc-utils/rename.c +++ b/misc-utils/rename.c @@ -127,8 +127,9 @@ static int do_file(char *from, char *to, char *s, int verbose, int noact, int no return ret; } -static void __attribute__ ((__noreturn__)) usage(FILE * out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] <expression> <replacement> <file>...\n"), @@ -146,7 +147,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out) fputs(USAGE_HELP, out); fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("rename(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } int main(int argc, char **argv) @@ -188,7 +189,7 @@ int main(int argc, char **argv) printf(UTIL_LINUX_VERSION); return EXIT_SUCCESS; case 'h': - usage(stdout); + usage(); default: errtryhelp(EXIT_FAILURE); } @@ -198,7 +199,7 @@ int main(int argc, char **argv) if (argc < 3) { warnx(_("not enough arguments")); - usage(stderr); + errtryhelp(EXIT_FAILURE); } from = argv[0]; diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c index 209ed7147..0bd53253d 100644 --- a/misc-utils/wipefs.c +++ b/misc-utils/wipefs.c @@ -451,8 +451,9 @@ do_wipe(struct wipe_desc *wp, const char *devname, int flags) static void __attribute__((__noreturn__)) -usage(FILE *out) +usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] <device>\n"), program_invocation_short_name); @@ -474,7 +475,7 @@ usage(FILE *out) fprintf(out, USAGE_MAN_TAIL("wipefs(8)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } @@ -525,7 +526,7 @@ main(int argc, char **argv) flags |= WP_FL_FORCE; break; case 'h': - usage(stdout); + usage(); break; case 'n': flags |= WP_FL_NOACT; @@ -552,8 +553,11 @@ main(int argc, char **argv) } } - if (optind == argc) - usage(stderr); + if (optind == argc) { + warnx(_("no device specified")); + errtryhelp(EXIT_FAILURE); + + } if ((flags & WP_FL_BACKUP) && !((flags & WP_FL_ALL) || has_offset)) warnx(_("The --backup option is meaningless in this context")); |