From 6e1eda6f229f87b77471ce6eb7cbf0ede7c8029e Mon Sep 17 00:00:00 2001 From: Ruediger Meier Date: Mon, 19 Jun 2017 20:52:50 +0200 Subject: misc: never use usage(stderr) Here we fix all cases where we have usage(FILE*) functions. Signed-off-by: Ruediger Meier --- sys-utils/dmesg.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'sys-utils/dmesg.c') diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index 37639ebe5..cd5da90f4 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -266,8 +266,9 @@ static int set_level_color(int log_level, const char *mesg, size_t mesgsz) return id >= 0 ? 0 : -1; } -static void __attribute__((__noreturn__)) usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; size_t i; fputs(USAGE_HEADER, out); @@ -320,7 +321,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) _(level_names[i].help)); fputs(USAGE_SEPARATOR, out); fprintf(out, USAGE_MAN_TAIL("dmesg(1)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } /* @@ -1422,7 +1423,7 @@ int main(int argc, char *argv[]) ctl.pager = 1; break; case 'h': - usage(stdout); + usage(); break; case 'k': ctl.fltr_fac = 1; @@ -1487,8 +1488,10 @@ int main(int argc, char *argv[]) } } - if (argc != optind) - usage(stderr); + if (argc != optind) { + warnx(_("bad usage")); + errtryhelp(EXIT_FAILURE); + } if ((is_timefmt(&ctl, RELTIME) || is_timefmt(&ctl, CTIME) || -- cgit v1.2.3-55-g7522