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/chmem.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'sys-utils/chmem.c') diff --git a/sys-utils/chmem.c b/sys-utils/chmem.c index 44733bf76..7f7be6ab6 100644 --- a/sys-utils/chmem.c +++ b/sys-utils/chmem.c @@ -234,8 +234,9 @@ static void parse_parameter(struct chmem_desc *desc, char *param) errx(EXIT_FAILURE, _("Invalid range: %s"), param); } -static void __attribute__((__noreturn__)) chmem_usage(FILE *out) +static void __attribute__((__noreturn__)) usage(void) { + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] [SIZE|RANGE|BLOCKRANGE]\n"), program_invocation_short_name); @@ -253,7 +254,7 @@ static void __attribute__((__noreturn__)) chmem_usage(FILE *out) fprintf(out, USAGE_MAN_TAIL("chmem(8)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } int main(int argc, char **argv) @@ -300,7 +301,7 @@ int main(int argc, char **argv) desc->use_blocks = 1; break; case 'h': - chmem_usage(stdout); + usage(); break; case 'v': desc->verbose = 1; @@ -313,8 +314,10 @@ int main(int argc, char **argv) } } - if ((argc == 1) || (argc != optind + 1) || (cmd == CMD_NONE)) - chmem_usage(stderr); + if ((argc == 1) || (argc != optind + 1) || (cmd == CMD_NONE)) { + warnx(_("bad usage")); + errtryhelp(EXIT_FAILURE); + } parse_parameter(desc, argv[optind]); -- cgit v1.2.3-55-g7522