diff options
author | Ruediger Meier | 2017-06-20 20:20:29 +0200 |
---|---|---|
committer | Ruediger Meier | 2017-06-26 14:38:24 +0200 |
commit | 86be6a32d3fd229dbb17bf5e3348a01e6e6e855a (patch) | |
tree | 04f05fd94b26d2b5a6304d69e93f2ec59e789e17 | |
parent | misc: cosmetics, remove argument from usage(int) (diff) | |
download | kernel-qcow2-util-linux-86be6a32d3fd229dbb17bf5e3348a01e6e6e855a.tar.gz kernel-qcow2-util-linux-86be6a32d3fd229dbb17bf5e3348a01e6e6e855a.tar.xz kernel-qcow2-util-linux-86be6a32d3fd229dbb17bf5e3348a01e6e6e855a.zip |
misc: cosmetics, remove argument from usage(FILE*)
This patch is trivial and changes nothing, because
we were always using usage(stdout)
Now all our usage() functions look very similar. If wanted we
could auto-generate another big cosmetical patch to remove all
the useless "FILE *out" constants and use printf and puts
rather than their f* friends. Such patch could be automatically
synchronized with the translation project (newlines!) to not
make the translators sick.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
40 files changed, 163 insertions, 126 deletions
diff --git a/Documentation/boilerplate.c b/Documentation/boilerplate.c index b70955d54..d0c163d8c 100644 --- a/Documentation/boilerplate.c +++ b/Documentation/boilerplate.c @@ -34,8 +34,9 @@ * Other usage() constants that are not demonstrated below: * USAGE_FUNCTIONS USAGE_COMMANDS USAGE_COLUMNS */ -static void __attribute__((__noreturn__)) usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] file...\n"), program_invocation_short_name); @@ -58,7 +59,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fputs(USAGE_HELP, out); fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("fixme-command-name(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } int main(int argc, char **argv) @@ -101,7 +102,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/disk-utils/cfdisk.c b/disk-utils/cfdisk.c index efff1b825..e17bc9167 100644 --- a/disk-utils/cfdisk.c +++ b/disk-utils/cfdisk.c @@ -2542,8 +2542,9 @@ static int ui_run(struct cfdisk *cf) return 0; } -static void __attribute__ ((__noreturn__)) usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %1$s [options] <disk>\n"), program_invocation_short_name); @@ -2562,7 +2563,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out) fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("cfdisk(8)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } int main(int argc, char *argv[]) @@ -2588,7 +2589,7 @@ int main(int argc, char *argv[]) while((c = getopt_long(argc, argv, "L::hVz", longopts, NULL)) != -1) { switch(c) { case 'h': - usage(stdout); + usage(); break; case 'L': colormode = UL_COLORMODE_AUTO; diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c index 2a75190f5..6f88780d7 100644 --- a/disk-utils/sfdisk.c +++ b/disk-utils/sfdisk.c @@ -1839,8 +1839,9 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv) return rc; } -static void __attribute__ ((__noreturn__)) usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, @@ -1906,7 +1907,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out) list_available_columns(out); fprintf(out, USAGE_MAN_TAIL("sfdisk(8)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } @@ -2042,7 +2043,7 @@ int main(int argc, char *argv[]) sf->act = ACT_SHOW_GEOM; break; case 'h': - usage(stdout); + usage(); break; case 'l': sf->act = ACT_LIST; diff --git a/login-utils/last.c b/login-utils/last.c index 50451b2e2..9cf6eb377 100644 --- a/login-utils/last.c +++ b/login-utils/last.c @@ -560,8 +560,9 @@ static int list(const struct last_control *ctl, struct utmpx *p, time_t logout_t } -static void __attribute__((__noreturn__)) usage(const struct last_control *ctl, FILE *out) +static void __attribute__((__noreturn__)) usage(const struct last_control *ctl) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _( " %s [options] [<username>...] [<tty>...]\n"), program_invocation_short_name); @@ -953,7 +954,7 @@ int main(int argc, char **argv) switch(c) { case 'h': - usage(&ctl, stdout); + usage(&ctl); break; case 'V': printf(UTIL_LINUX_VERSION); diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c index c6c849e14..c15b347f2 100644 --- a/login-utils/lslogins.c +++ b/login-utils/lslogins.c @@ -1219,8 +1219,9 @@ static int parse_time_mode(const char *s) errx(EXIT_FAILURE, _("unknown time format: %s"), s); } -static void __attribute__((__noreturn__)) usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; size_t i; fputs(USAGE_HEADER, out); @@ -1261,7 +1262,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fprintf(out, USAGE_MAN_TAIL("lslogins(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } int main(int argc, char *argv[]) @@ -1365,7 +1366,7 @@ int main(int argc, char *argv[]) groups = optarg; break; case 'h': - usage(stdout); + usage(); break; case 'L': add_column(columns, ncolumns++, COL_LAST_TTY); diff --git a/login-utils/newgrp.c b/login-utils/newgrp.c index 63a45cd6a..767ae4bcf 100644 --- a/login-utils/newgrp.c +++ b/login-utils/newgrp.c @@ -166,19 +166,20 @@ static int allow_setgid(const struct passwd *pe, const struct group *ge) return FALSE; } -static void __attribute__((__noreturn__)) usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { - fprintf(out, USAGE_HEADER); + FILE *out = stdout; + fputs(USAGE_HEADER, out); fprintf(out, _(" %s <group>\n"), program_invocation_short_name); fputs(USAGE_SEPARATOR, out); fputs(_("Log in to a new group.\n"), out); - fprintf(out, USAGE_OPTIONS); - fprintf(out, USAGE_HELP); - fprintf(out, USAGE_VERSION); + fputs(USAGE_OPTIONS, out); + fputs(USAGE_HELP,out); + fputs(USAGE_VERSION,out); fprintf(out, USAGE_MAN_TAIL("newgrp(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } int main(int argc, char *argv[]) @@ -204,7 +205,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/login-utils/nologin.c b/login-utils/nologin.c index e950d2a3f..00b4b8af8 100644 --- a/login-utils/nologin.c +++ b/login-utils/nologin.c @@ -19,8 +19,9 @@ * Always return EXIT_FAILURE (1), don't try to be smart! */ -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); @@ -53,7 +54,7 @@ int main(int argc, char *argv[]) while ((c = getopt_long(argc, argv, "hV", longopts, NULL)) != -1) { switch (c) { case 'h': - usage(stdout); + usage(); break; case 'V': printf(UTIL_LINUX_VERSION); diff --git a/login-utils/utmpdump.c b/login-utils/utmpdump.c index 385a96bf9..5bcb4c35f 100644 --- a/login-utils/utmpdump.c +++ b/login-utils/utmpdump.c @@ -296,8 +296,9 @@ static void undump(FILE *in, FILE *out) free(linestart); } -static void __attribute__((__noreturn__)) usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, @@ -314,7 +315,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("utmpdump(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } int main(int argc, char **argv) @@ -356,7 +357,7 @@ int main(int argc, char **argv) break; case 'h': - usage(stdout); + usage(); break; case 'V': printf(UTIL_LINUX_VERSION); diff --git a/login-utils/vipw.c b/login-utils/vipw.c index 7d4a831de..e3cca4906 100644 --- a/login-utils/vipw.c +++ b/login-utils/vipw.c @@ -296,8 +296,9 @@ static void edit_file(int is_shadow) ulckpwdf(); } -static void __attribute__((__noreturn__)) usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, " %s\n", program_invocation_short_name); @@ -308,7 +309,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fputs(USAGE_HELP, out); fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("vipw(8)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } int main(int argc, char *argv[]) @@ -339,7 +340,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/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/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/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/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/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/sys-utils/blkzone.c b/sys-utils/blkzone.c index 8fd55c066..ee4902e45 100644 --- a/sys-utils/blkzone.c +++ b/sys-utils/blkzone.c @@ -290,8 +290,9 @@ static int blkzone_reset(struct blkzone_control *ctl) return 0; } -static void __attribute__((__noreturn__)) usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; size_t i; fputs(USAGE_HEADER, out); @@ -314,7 +315,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("blkzone(8)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } int main(int argc, char **argv) @@ -362,7 +363,7 @@ int main(int argc, char **argv) switch (c) { case 'h': - usage(stdout); + usage(); break; case 'c': ctl.count = strtou32_or_err(optarg, diff --git a/sys-utils/ctrlaltdel.c b/sys-utils/ctrlaltdel.c index 840945082..98c8ed832 100644 --- a/sys-utils/ctrlaltdel.c +++ b/sys-utils/ctrlaltdel.c @@ -21,19 +21,20 @@ #define LINUX_REBOOT_CMD_CAD_ON 0x89ABCDEF #define LINUX_REBOOT_CMD_CAD_OFF 0x00000000 -static void __attribute__ ((__noreturn__)) usage(FILE * out) +static void __attribute__((__noreturn__)) usage(void) { - fprintf(out, USAGE_HEADER); + FILE *out = stdout; + fputs(USAGE_HEADER, out); fprintf(out, _(" %s hard|soft\n"), program_invocation_short_name); - fprintf(out, USAGE_SEPARATOR); + fputs(USAGE_SEPARATOR, out); fprintf(out, _("Set the function of the Ctrl-Alt-Del combination.\n")); - fprintf(out, USAGE_OPTIONS); - fprintf(out, USAGE_HELP); - fprintf(out, USAGE_VERSION); + fputs(USAGE_OPTIONS, out); + fputs(USAGE_HELP, out); + fputs(USAGE_VERSION,out); fprintf(out, USAGE_MAN_TAIL("ctrlaltdel(8)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } static int get_cad(void) @@ -98,7 +99,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/sys-utils/eject.c b/sys-utils/eject.c index 7cdd2db6e..296e5cba5 100644 --- a/sys-utils/eject.c +++ b/sys-utils/eject.c @@ -127,8 +127,9 @@ static inline void info(const char *fmt, ...) va_end(va); } -static void __attribute__ ((__noreturn__)) usage(FILE * out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] [<device>|<mountpoint>]\n"), program_invocation_short_name); @@ -164,7 +165,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out) fputs(_("\nBy default tries -r, -s, -f, and -q in order until success.\n"), out); fprintf(out, USAGE_MAN_TAIL("eject(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } @@ -223,7 +224,7 @@ static void parse_args(struct eject_control *ctl, int argc, char **argv) ctl->F_option = 1; break; case 'h': - usage(stdout); + usage(); break; case 'i': ctl->i_option = 1; diff --git a/sys-utils/fallocate.c b/sys-utils/fallocate.c index 7bbc36865..a2d212552 100644 --- a/sys-utils/fallocate.c +++ b/sys-utils/fallocate.c @@ -76,8 +76,9 @@ static int verbose; static char *filename; -static void __attribute__((__noreturn__)) usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] <filename>\n"), program_invocation_short_name); @@ -105,7 +106,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fprintf(out, USAGE_MAN_TAIL("fallocate(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } static loff_t cvtnum(char *s) @@ -329,7 +330,7 @@ int main(int argc, char **argv) switch(c) { case 'h': - usage(stdout); + usage(); break; case 'c': mode |= FALLOC_FL_COLLAPSE_RANGE; diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c index 07ad61385..f3448a569 100644 --- a/sys-utils/hwclock.c +++ b/sys-utils/hwclock.c @@ -1200,8 +1200,9 @@ static void out_version(void) } static void __attribute__((__noreturn__)) -usage(const struct hwclock_control *ctl, FILE *out) +usage(const struct hwclock_control *ctl) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fputs(_(" hwclock [function] [option...]\n"), out); @@ -1451,7 +1452,7 @@ int main(int argc, char **argv) out_version(); return 0; case 'h': /* --help */ - usage(&ctl, stdout); + usage(&ctl); default: errtryhelp(EXIT_FAILURE); } diff --git a/sys-utils/ipcs.c b/sys-utils/ipcs.c index 3c4e5df0e..943b09c4a 100644 --- a/sys-utils/ipcs.c +++ b/sys-utils/ipcs.c @@ -46,8 +46,9 @@ static void print_msg (int id, int unit); /* we read time as int64_t from /proc, so cast... */ #define xctime(_x) ctime((time_t *) (_x)) -static void __attribute__ ((__noreturn__)) usage(FILE * out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %1$s [resource-option...] [output-option]\n" " %1$s -m|-q|-s -i <id>\n"), program_invocation_short_name); @@ -78,7 +79,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out) fputs(_(" -b, --bytes show sizes in bytes\n"), out); fprintf(out, USAGE_MAN_TAIL("ipcs(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } int main (int argc, char **argv) @@ -150,7 +151,7 @@ int main (int argc, char **argv) unit = IPC_UNIT_BYTES; break; case 'h': - usage(stdout); + usage(); case 'V': printf(UTIL_LINUX_VERSION); return EXIT_SUCCESS; diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c index 05d3ec620..6cadd0ef5 100644 --- a/sys-utils/lsns.c +++ b/sys-utils/lsns.c @@ -603,8 +603,9 @@ static int show_namespace_processes(struct lsns *ls, struct lsns_namespace *ns) return 0; } -static void __attribute__ ((__noreturn__)) usage(FILE * out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; size_t i; fputs(USAGE_HEADER, out); @@ -635,7 +636,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out) fprintf(out, USAGE_MAN_TAIL("lsns(8)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } @@ -698,7 +699,7 @@ int main(int argc, char *argv[]) ls.fltr_pid = strtos32_or_err(optarg, _("invalid PID argument")); break; case 'h': - usage(stdout); + usage(); case 'n': ls.no_headings = 1; break; diff --git a/sys-utils/prlimit.c b/sys-utils/prlimit.c index 302103f8b..44db54ca5 100644 --- a/sys-utils/prlimit.c +++ b/sys-utils/prlimit.c @@ -151,8 +151,9 @@ static int prlimit(pid_t p, int resource, } #endif -static void __attribute__ ((__noreturn__)) usage(FILE * out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; size_t i; fputs(USAGE_HEADER, out); @@ -199,7 +200,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out) fprintf(out, USAGE_MAN_TAIL("prlimit(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } static inline int get_column_id(int num) @@ -584,7 +585,7 @@ int main(int argc, char **argv) pid = strtos32_or_err(optarg, _("invalid PID argument")); break; case 'h': - usage(stdout); + usage(); case 'o': ncolumns = string_to_idarray(optarg, columns, ARRAY_SIZE(columns), diff --git a/sys-utils/readprofile.c b/sys-utils/readprofile.c index f18fa9bf2..dc14c64f2 100644 --- a/sys-utils/readprofile.c +++ b/sys-utils/readprofile.c @@ -97,9 +97,9 @@ static char *boot_uname_r_str(void) return s; } -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); @@ -125,7 +125,7 @@ static void __attribute__ ((__noreturn__)) fputs(USAGE_HELP, out); fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("readprofile(8)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } int main(int argc, char **argv) @@ -211,7 +211,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/sys-utils/setpriv.c b/sys-utils/setpriv.c index 8d996e8be..310e6938d 100644 --- a/sys-utils/setpriv.c +++ b/sys-utils/setpriv.c @@ -92,8 +92,9 @@ struct privctx { const char *apparmor_profile; }; -static void __attribute__((__noreturn__)) usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] <program> [<argument>...]\n"), program_invocation_short_name); @@ -127,7 +128,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fputs(_(" This tool can be dangerous. Read the manpage, and be careful.\n"), out); fprintf(out, USAGE_MAN_TAIL("setpriv(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } static int real_cap_last_cap(void) @@ -797,7 +798,7 @@ int main(int argc, char **argv) opts.apparmor_profile = optarg; break; case 'h': - usage(stdout); + usage(); case 'V': printf(UTIL_LINUX_VERSION); return EXIT_SUCCESS; diff --git a/sys-utils/wdctl.c b/sys-utils/wdctl.c index 1790e8993..28a24c1f8 100644 --- a/sys-utils/wdctl.c +++ b/sys-utils/wdctl.c @@ -165,8 +165,9 @@ static struct colinfo *get_column_info(unsigned num) return &infos[ get_column_id(num) ]; } -static void __attribute__ ((__noreturn__)) usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; size_t i; fputs(USAGE_HEADER, out); @@ -201,7 +202,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out) fprintf(out, USAGE_MAN_TAIL("wdctl(8)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } static void add_flag_line(struct libscols_table *table, struct wdinfo *wd, const struct wdflag *fl) @@ -531,7 +532,7 @@ int main(int argc, char *argv[]) printf(UTIL_LINUX_VERSION); return EXIT_SUCCESS; case 'h': - usage(stdout); + usage(); case 'F': noflags = 1; break; diff --git a/sys-utils/zramctl.c b/sys-utils/zramctl.c index 7b001fe5d..948c58925 100644 --- a/sys-utils/zramctl.c +++ b/sys-utils/zramctl.c @@ -517,8 +517,9 @@ static void status(struct zram *z) scols_unref_table(tb); } -static void __attribute__ ((__noreturn__)) usage(FILE * out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; size_t i; fputs(USAGE_HEADER, out); @@ -550,7 +551,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out) fprintf(out, " %11s %s\n", infos[i].name, _(infos[i].help)); fprintf(out, USAGE_MAN_TAIL("zramctl(8)")); - exit(out == stderr ? 1 : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } /* actions */ @@ -642,7 +643,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/term-utils/script.c b/term-utils/script.c index f2fc2f59c..c59ce7b11 100644 --- a/term-utils/script.c +++ b/term-utils/script.c @@ -154,8 +154,9 @@ static inline time_t script_time(time_t *t) # define script_time(x) time(x) #endif -static void __attribute__((__noreturn__)) usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] [file]\n"), program_invocation_short_name); @@ -174,7 +175,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) " -h, --help display this help and exit\n\n"), out); fprintf(out, USAGE_MAN_TAIL("script(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } static void die_if_link(const struct script_control *ctl) @@ -736,7 +737,7 @@ int main(int argc, char **argv) exit(EXIT_SUCCESS); break; case 'h': - usage(stdout); + usage(); break; default: errtryhelp(EXIT_FAILURE); diff --git a/term-utils/scriptreplay.c b/term-utils/scriptreplay.c index 5fd3ecb16..a83f9a2eb 100644 --- a/term-utils/scriptreplay.c +++ b/term-utils/scriptreplay.c @@ -36,8 +36,9 @@ #define SCRIPT_MIN_DELAY 0.0001 /* from original sripreplay.pl */ static void __attribute__((__noreturn__)) -usage(FILE *out) +usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [-t] timingfile [typescript] [divisor]\n"), @@ -55,7 +56,7 @@ usage(FILE *out) " -h, --help display this help and exit\n\n"), out); fprintf(out, USAGE_MAN_TAIL("scriptreplay(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } static double @@ -172,7 +173,7 @@ main(int argc, char *argv[]) printf(UTIL_LINUX_VERSION); exit(EXIT_SUCCESS); case 'h': - usage(stdout); + usage(); default: errtryhelp(EXIT_FAILURE); } diff --git a/term-utils/wall.c b/term-utils/wall.c index 527e4b6df..803a02976 100644 --- a/term-utils/wall.c +++ b/term-utils/wall.c @@ -78,8 +78,9 @@ static char *makemsg(char *fname, char **mvec, int mvecsz, size_t *mbufsize, int print_banner); -static void __attribute__((__noreturn__)) usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] [<file> | <message>]\n"), program_invocation_short_name); @@ -96,7 +97,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("wall(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } struct group_workspace { @@ -224,7 +225,7 @@ int main(int argc, char **argv) printf(UTIL_LINUX_VERSION); exit(EXIT_SUCCESS); case 'h': - usage(stdout); + usage(); default: errtryhelp(EXIT_FAILURE); } diff --git a/text-utils/colcrt.c b/text-utils/colcrt.c index ff8cd4694..375d0d6f0 100644 --- a/text-utils/colcrt.c +++ b/text-utils/colcrt.c @@ -75,8 +75,9 @@ struct colcrt_control { half_lines: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] [<file>...]\n"), program_invocation_short_name); @@ -93,7 +94,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fprintf(out, USAGE_MAN_TAIL("colcrt(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } static void trim_trailing_spaces(wchar_t *s) @@ -264,7 +265,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/text-utils/colrm.c b/text-utils/colrm.c index b2816cd07..ebebca0bf 100644 --- a/text-utils/colrm.c +++ b/text-utils/colrm.c @@ -54,8 +54,9 @@ COLRM removes unwanted columns from a file Jeff Schriebman UC Berkeley 11-74 */ -static void __attribute__ ((__noreturn__)) usage(FILE * out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fprintf(out, _("\nUsage:\n" " %s [startcol [endcol]]\n"), program_invocation_short_name); @@ -69,7 +70,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out) fprintf(out, _("%s reads from standard input and writes to standard output\n\n"), program_invocation_short_name); fprintf(out, USAGE_MAN_TAIL("colrm(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } static int process_input(unsigned long first, unsigned long last) @@ -176,7 +177,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/text-utils/hexdump.c b/text-utils/hexdump.c index bf0631654..53d10a6d9 100644 --- a/text-utils/hexdump.c +++ b/text-utils/hexdump.c @@ -131,7 +131,7 @@ parse_args(int argc, char **argv, struct hexdump *hex) add_fmt("\"%07.7_ax \" 8/2 \" %04x \" \"\\n\"", hex); break; case 'h': - usage(stdout); + usage(); case 'V': printf(UTIL_LINUX_VERSION); exit(EXIT_SUCCESS); @@ -149,8 +149,9 @@ parse_args(int argc, char **argv, struct hexdump *hex) return optind; } -void __attribute__((__noreturn__)) usage(FILE *out) +void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] <file>...\n"), program_invocation_short_name); @@ -177,7 +178,7 @@ void __attribute__((__noreturn__)) usage(FILE *out) fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("hexdump(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } int main(int argc, char **argv) diff --git a/text-utils/hexdump.h b/text-utils/hexdump.h index 741a57ad2..4a8d10916 100644 --- a/text-utils/hexdump.h +++ b/text-utils/hexdump.h @@ -101,7 +101,7 @@ void add_fmt(const char *, struct hexdump *); void rewrite_rules(struct hexdump_fs *, struct hexdump *); void addfile(char *, struct hexdump *); void display(struct hexdump *); -void __attribute__((__noreturn__)) usage(FILE *out); +void __attribute__((__noreturn__)) usage(void); void conv_c(struct hexdump_pr *, u_char *); void conv_u(struct hexdump_pr *, u_char *); int next(char **, struct hexdump *); diff --git a/text-utils/line.c b/text-utils/line.c index 486e5dd31..15d7d4adf 100644 --- a/text-utils/line.c +++ b/text-utils/line.c @@ -24,8 +24,9 @@ #include "nls.h" #include "widechar.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); @@ -36,7 +37,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fputs(USAGE_HELP, out); fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("line(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } int main(int argc, char **argv) @@ -62,7 +63,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/text-utils/rev.c b/text-utils/rev.c index feed2b167..9a778e383 100644 --- a/text-utils/rev.c +++ b/text-utils/rev.c @@ -71,8 +71,9 @@ static void sig_handler(int signo __attribute__ ((__unused__))) _exit(EXIT_SUCCESS); } -static void __attribute__ ((__noreturn__)) usage(FILE * out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fprintf(out, _("Usage: %s [options] [file ...]\n"), program_invocation_short_name); @@ -84,7 +85,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out) fputs(USAGE_VERSION, out); fprintf(out, USAGE_MAN_TAIL("rev(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } static void reverse_str(wchar_t *str, size_t n) @@ -125,7 +126,7 @@ int main(int argc, char *argv[]) printf(UTIL_LINUX_VERSION); exit(EXIT_SUCCESS); case 'h': - usage(stdout); + usage(); default: errtryhelp(EXIT_FAILURE); } diff --git a/text-utils/ul.c b/text-utils/ul.c index 736483ef4..a2ad5ea42 100644 --- a/text-utils/ul.c +++ b/text-utils/ul.c @@ -135,9 +135,9 @@ static int halfpos; static int upln; static int iflag; -static void __attribute__((__noreturn__)) -usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] [<file> ...]\n"), program_invocation_short_name); @@ -153,7 +153,7 @@ usage(FILE *out) fprintf(out, USAGE_MAN_TAIL("ul(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } int main(int argc, char **argv) @@ -196,7 +196,7 @@ int main(int argc, char **argv) printf(UTIL_LINUX_VERSION); return EXIT_SUCCESS; case 'h': - usage(stdout); + usage(); default: errtryhelp(EXIT_FAILURE); } |