diff options
author | Karel Zak | 2017-06-26 15:58:37 +0200 |
---|---|---|
committer | Karel Zak | 2017-06-26 15:58:37 +0200 |
commit | 47ccf06b4728130beb19b05a5c13a87e2807ad3e (patch) | |
tree | ca6073f0053d6e362b623d2817edcdb3ae45d93d /misc-utils | |
parent | script: rename fixtty() to enable_rawmode_tty() (diff) | |
parent | misc: cosmetics, remove argument from usage(FILE*) (diff) | |
download | kernel-qcow2-util-linux-47ccf06b4728130beb19b05a5c13a87e2807ad3e.tar.gz kernel-qcow2-util-linux-47ccf06b4728130beb19b05a5c13a87e2807ad3e.tar.xz kernel-qcow2-util-linux-47ccf06b4728130beb19b05a5c13a87e2807ad3e.zip |
Merge branch 'usage-part2' of https://github.com/rudimeier/util-linux
* 'usage-part2' of https://github.com/rudimeier/util-linux:
misc: cosmetics, remove argument from usage(FILE*)
misc: cosmetics, remove argument from usage(int)
misc: never use usage(stderr)
misc: never use usage(ERROR)
misc: cleanup and fix --unknownopt issues
flock, getopt: write --help to stdout and return 0
tools: add checkusage.sh
Diffstat (limited to 'misc-utils')
-rw-r--r-- | misc-utils/blkid.c | 8 | ||||
-rw-r--r-- | misc-utils/cal.c | 12 | ||||
-rw-r--r-- | misc-utils/fincore.c | 7 | ||||
-rw-r--r-- | misc-utils/findfs.c | 14 | ||||
-rw-r--r-- | misc-utils/findmnt.c | 7 | ||||
-rw-r--r-- | misc-utils/getopt.c | 48 | ||||
-rw-r--r-- | misc-utils/kill.c | 7 | ||||
-rw-r--r-- | misc-utils/logger.c | 7 | ||||
-rw-r--r-- | misc-utils/look.c | 12 | ||||
-rw-r--r-- | misc-utils/lsblk.c | 7 | ||||
-rw-r--r-- | misc-utils/lslocks.c | 7 | ||||
-rw-r--r-- | misc-utils/mcookie.c | 7 | ||||
-rw-r--r-- | misc-utils/namei.c | 10 | ||||
-rw-r--r-- | misc-utils/rename.c | 9 | ||||
-rw-r--r-- | misc-utils/uuidd.c | 7 | ||||
-rw-r--r-- | misc-utils/uuidgen.c | 7 | ||||
-rw-r--r-- | misc-utils/wipefs.c | 14 |
17 files changed, 104 insertions, 86 deletions
diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c index 52179e5e1..f4757e8c8 100644 --- a/misc-utils/blkid.c +++ b/misc-utils/blkid.c @@ -68,9 +68,9 @@ static void print_version(FILE *out) LIBBLKID_VERSION, LIBBLKID_DATE); } -static void usage(int error) +static void __attribute__((__noreturn__)) usage(void) { - FILE *out = error ? stderr : stdout; + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _( " %s --label <label> | --uuid <uuid>\n\n"), program_invocation_short_name); @@ -106,7 +106,7 @@ static void usage(int error) fputs(USAGE_HELP, out); fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("blkid(8)")); - exit(error); + exit(EXIT_SUCCESS); } /* @@ -794,7 +794,7 @@ int main(int argc, char **argv) /* ignore - backward compatibility */ break; case 'h': - usage(0); + usage(); break; default: errtryhelp(EXIT_FAILURE); 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/fincore.c b/misc-utils/fincore.c index 84b83c6f2..f1b9fa758 100644 --- a/misc-utils/fincore.c +++ b/misc-utils/fincore.c @@ -258,8 +258,9 @@ static int fincore_name(struct fincore_control *ctl, return rc; } -static void __attribute__((__noreturn__)) usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; size_t i; fputs(USAGE_HEADER, out); @@ -283,7 +284,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fprintf(out, USAGE_MAN_TAIL("fincore(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } int main(int argc, char ** argv) @@ -334,7 +335,7 @@ int main(int argc, char ** argv) printf(UTIL_LINUX_VERSION); return EXIT_SUCCESS; case 'h': - usage(stdout); + usage(); default: errtryhelp(EXIT_FAILURE); } diff --git a/misc-utils/findfs.c b/misc-utils/findfs.c index 7d2d803dd..c01dc1d53 100644 --- a/misc-utils/findfs.c +++ b/misc-utils/findfs.c @@ -22,9 +22,9 @@ #define FINDFS_NOT_FOUND 1 /* label or uuid cannot be found */ #define FINDFS_USAGE_ERROR 2 /* user did something unexpected */ -static void __attribute__((__noreturn__)) usage(int rc) +static void __attribute__((__noreturn__)) usage(void) { - FILE *out = rc ? stderr : stdout; + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] {LABEL,UUID,PARTUUID,PARTLABEL}=<value>\n"), program_invocation_short_name); @@ -36,7 +36,7 @@ static void __attribute__((__noreturn__)) usage(int rc) fputs(USAGE_HELP, out); fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("findfs(8)")); - exit(rc); + exit(FINDFS_SUCCESS); } int main(int argc, char **argv) @@ -54,10 +54,12 @@ int main(int argc, char **argv) textdomain(PACKAGE); atexit(close_stdout); - if (argc != 2) + if (argc != 2) { /* we return '2' for backward compatibility * with version from e2fsprogs */ - usage(FINDFS_USAGE_ERROR); + warnx(_("bad usage")); + errtryhelp(FINDFS_USAGE_ERROR); + } while ((c = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1) switch (c) { @@ -65,7 +67,7 @@ int main(int argc, char **argv) printf(UTIL_LINUX_VERSION); return FINDFS_SUCCESS; case 'h': - usage(FINDFS_SUCCESS); + usage(); default: errtryhelp(FINDFS_USAGE_ERROR); } diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c index 7acc60a26..5394d1a60 100644 --- a/misc-utils/findmnt.c +++ b/misc-utils/findmnt.c @@ -1182,8 +1182,9 @@ static int uniq_fs_target_cmp( return !mnt_fs_match_target(a, mnt_fs_get_target(b), cache); } -static void __attribute__((__noreturn__)) usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; size_t i; fputs(USAGE_HEADER, out); @@ -1254,7 +1255,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fprintf(out, USAGE_MAN_TAIL("findmnt(8)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } int main(int argc, char *argv[]) @@ -1377,7 +1378,7 @@ int main(int argc, char *argv[]) flags |= FL_EVALUATE; break; case 'h': - usage(stdout); + usage(); break; case 'i': flags |= FL_INVERT; diff --git a/misc-utils/getopt.c b/misc-utils/getopt.c index af4cf386a..87d088ed5 100644 --- a/misc-utils/getopt.c +++ b/misc-utils/getopt.c @@ -243,9 +243,7 @@ static void __attribute__ ((__noreturn__)) parse_error(const char *message) { if (message) warnx("%s", message); - fprintf(stderr, _("Try `%s --help' for more information.\n"), - program_invocation_short_name); - exit(PARAMETER_EXIT_CODE); + errtryhelp(PARAMETER_EXIT_CODE); } @@ -325,33 +323,33 @@ static shell_t shell_type(const char *new_shell) parse_error(_("unknown shell after -s or --shell argument")); } -static void __attribute__ ((__noreturn__)) print_help(void) +static void __attribute__((__noreturn__)) usage(void) { - fputs(USAGE_HEADER, stderr); - fprintf(stderr, _( + fputs(USAGE_HEADER, stdout); + printf(_( " %1$s <optstring> <parameters>\n" " %1$s [options] [--] <optstring> <parameters>\n" " %1$s [options] -o|--options <optstring> [options] [--] <parameters>\n"), program_invocation_short_name); - fputs(USAGE_SEPARATOR, stderr); - fputs(_("Parse command options.\n"), stderr); - - fputs(USAGE_OPTIONS, stderr); - fputs(_(" -a, --alternative allow long options starting with single -\n"), stderr); - fputs(_(" -l, --longoptions <longopts> the long options to be recognized\n"), stderr); - fputs(_(" -n, --name <progname> the name under which errors are reported\n"), stderr); - fputs(_(" -o, --options <optstring> the short options to be recognized\n"), stderr); - fputs(_(" -q, --quiet disable error reporting by getopt(3)\n"), stderr); - fputs(_(" -Q, --quiet-output no normal output\n"), stderr); - fputs(_(" -s, --shell <shell> set quoting conventions to those of <shell>\n"), stderr); - fputs(_(" -T, --test test for getopt(1) version\n"), stderr); - fputs(_(" -u, --unquoted do not quote the output\n"), stderr); - fputs(USAGE_SEPARATOR, stderr); - fputs(USAGE_HELP, stderr); - fputs(USAGE_VERSION, stderr); - fprintf(stderr, USAGE_MAN_TAIL("getopt(1)")); - exit(PARAMETER_EXIT_CODE); + fputs(USAGE_SEPARATOR, stdout); + fputs(_("Parse command options.\n"), stdout); + + fputs(USAGE_OPTIONS, stdout); + fputs(_(" -a, --alternative allow long options starting with single -\n"), stdout); + fputs(_(" -l, --longoptions <longopts> the long options to be recognized\n"), stdout); + fputs(_(" -n, --name <progname> the name under which errors are reported\n"), stdout); + fputs(_(" -o, --options <optstring> the short options to be recognized\n"), stdout); + fputs(_(" -q, --quiet disable error reporting by getopt(3)\n"), stdout); + fputs(_(" -Q, --quiet-output no normal output\n"), stdout); + fputs(_(" -s, --shell <shell> set quoting conventions to those of <shell>\n"), stdout); + fputs(_(" -T, --test test for getopt(1) version\n"), stdout); + fputs(_(" -u, --unquoted do not quote the output\n"), stdout); + fputs(USAGE_SEPARATOR, stdout); + fputs(USAGE_HELP, stdout); + fputs(USAGE_VERSION, stdout); + printf(USAGE_MAN_TAIL("getopt(1)")); + exit(EXIT_SUCCESS); } int main(int argc, char *argv[]) @@ -417,7 +415,7 @@ int main(int argc, char *argv[]) getopt_long_fp = getopt_long_only; break; case 'h': - print_help(); + usage(); case 'o': free(ctl.optstr); ctl.optstr = xstrdup(optarg); diff --git a/misc-utils/kill.c b/misc-utils/kill.c index 9046d76d1..ecee26c4e 100644 --- a/misc-utils/kill.c +++ b/misc-utils/kill.c @@ -296,8 +296,9 @@ static int arg_to_signum(char *arg, int maskbit) return signame_to_signum(arg); } -static void __attribute__((__noreturn__)) usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] <pid>|<name>...\n"), program_invocation_short_name); @@ -321,7 +322,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("kill(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } static char **parse_arguments(int argc, char **argv, struct kill_control *ctl) @@ -345,7 +346,7 @@ static char **parse_arguments(int argc, char **argv, struct kill_control *ctl) exit(EXIT_SUCCESS); } if (!strcmp(arg, "-h") || !strcmp(arg, "--help")) - usage(stdout); + usage(); if (!strcmp(arg, "--verbose")) { ctl->verbose = 1; continue; diff --git a/misc-utils/logger.c b/misc-utils/logger.c index 653adae94..0ae5c61d0 100644 --- a/misc-utils/logger.c +++ b/misc-utils/logger.c @@ -988,8 +988,9 @@ static void logger_close(const struct logger_ctl *ctl) free(ctl->hdr); } -static void __attribute__ ((__noreturn__)) usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] [<message>]\n"), program_invocation_short_name); @@ -1030,7 +1031,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out) fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("logger(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } /* @@ -1160,7 +1161,7 @@ int main(int argc, char **argv) printf(UTIL_LINUX_VERSION); exit(EXIT_SUCCESS); case 'h': - usage(stdout); + usage(); case OPT_OCTET_COUNT: ctl.octet_count = 1; break; 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/lsblk.c b/misc-utils/lsblk.c index dddd2a068..d997bc71e 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -1622,8 +1622,9 @@ static int cmp_u64_cells(struct libscols_cell *a, return *adata == *bdata ? 0 : *adata >= *bdata ? 1 : -1; } -static void __attribute__((__noreturn__)) help(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; size_t i; fputs(USAGE_HEADER, out); @@ -1667,7 +1668,7 @@ static void __attribute__((__noreturn__)) help(FILE *out) fprintf(out, USAGE_MAN_TAIL("lsblk(8)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } static void check_sysdevblock(void) @@ -1766,7 +1767,7 @@ int main(int argc, char *argv[]) parse_excludes(optarg); break; case 'h': - help(stdout); + usage(); break; case 'J': lsblk->flags |= LSBLK_JSON; diff --git a/misc-utils/lslocks.c b/misc-utils/lslocks.c index b33ffc179..54440496a 100644 --- a/misc-utils/lslocks.c +++ b/misc-utils/lslocks.c @@ -484,8 +484,9 @@ static int show_locks(struct list_head *locks) } -static void __attribute__ ((__noreturn__)) usage(FILE * out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; size_t i; fputs(USAGE_HEADER, out); @@ -516,7 +517,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out) fprintf(out, USAGE_MAN_TAIL("lslocks(8)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } int main(int argc, char *argv[]) @@ -569,7 +570,7 @@ int main(int argc, char *argv[]) printf(UTIL_LINUX_VERSION); return EXIT_SUCCESS; case 'h': - usage(stdout); + usage(); case 'n': no_headings = 1; break; diff --git a/misc-utils/mcookie.c b/misc-utils/mcookie.c index cc2d7ce6a..89b9a01eb 100644 --- a/misc-utils/mcookie.c +++ b/misc-utils/mcookie.c @@ -76,8 +76,9 @@ static uint64_t hash_file(struct mcookie_control *ctl, int fd) return count; } -static void __attribute__ ((__noreturn__)) usage(FILE * out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options]\n"), program_invocation_short_name); @@ -94,7 +95,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out) fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("mcookie(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } static void randomness_from_files(struct mcookie_control *ctl) @@ -167,7 +168,7 @@ int main(int argc, char **argv) printf(UTIL_LINUX_VERSION); return EXIT_SUCCESS; case 'h': - usage(stdout); + usage(); default: errtryhelp(EXIT_FAILURE); } diff --git a/misc-utils/namei.c b/misc-utils/namei.c index 0b0a0579c..dcaf5d2eb 100644 --- a/misc-utils/namei.c +++ b/misc-utils/namei.c @@ -320,10 +320,10 @@ print_namei(struct namei *nm, char *path) return 0; } -static void usage(int rc) +static void __attribute__((__noreturn__)) usage(void) { const char *p = program_invocation_short_name; - FILE *out = rc == EXIT_FAILURE ? stderr : stdout; + FILE *out = stdout; if (!*p) p = "namei"; @@ -346,7 +346,7 @@ static void usage(int rc) " -v, --vertical vertical align of modes and owners\n"), out); fprintf(out, USAGE_MAN_TAIL("namei(1)")); - exit(rc); + exit(EXIT_SUCCESS); } static const struct option longopts[] = @@ -376,7 +376,7 @@ main(int argc, char **argv) while ((c = getopt_long(argc, argv, "hVlmnovx", longopts, NULL)) != -1) { switch(c) { case 'h': - usage(EXIT_SUCCESS); + usage(); break; case 'V': printf(UTIL_LINUX_VERSION); @@ -406,7 +406,7 @@ main(int argc, char **argv) if (optind == argc) { warnx(_("pathname argument is missing")); - usage(EXIT_FAILURE); + errtryhelp(EXIT_FAILURE); } ucache = new_idcache(); 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/uuidd.c b/misc-utils/uuidd.c index 371975d63..faaa0c12f 100644 --- a/misc-utils/uuidd.c +++ b/misc-utils/uuidd.c @@ -58,8 +58,9 @@ struct uuidd_cxt_t { no_sock: 1; }; -static void __attribute__ ((__noreturn__)) usage(FILE * out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options]\n"), program_invocation_short_name); fputs(USAGE_SEPARATOR, out); @@ -81,7 +82,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out) fputs(USAGE_HELP, out); fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("uuidd(8)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } static void create_daemon(void) @@ -633,7 +634,7 @@ int main(int argc, char **argv) printf(UTIL_LINUX_VERSION); return EXIT_SUCCESS; case 'h': - usage(stdout); + usage(); default: errtryhelp(EXIT_FAILURE); } diff --git a/misc-utils/uuidgen.c b/misc-utils/uuidgen.c index 4c1d47d5e..77fda2fb3 100644 --- a/misc-utils/uuidgen.c +++ b/misc-utils/uuidgen.c @@ -18,8 +18,9 @@ #include "c.h" #include "closestream.h" -static void __attribute__ ((__noreturn__)) usage(FILE * out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options]\n"), program_invocation_short_name); @@ -34,7 +35,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out) fputs(USAGE_HELP, out); fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("uuidgen(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } int @@ -70,7 +71,7 @@ main (int argc, char *argv[]) printf(UTIL_LINUX_VERSION); return EXIT_SUCCESS; case 'h': - usage(stdout); + usage(); default: errtryhelp(EXIT_FAILURE); } 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")); |