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 --- disk-utils/mkfs.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'disk-utils/mkfs.c') diff --git a/disk-utils/mkfs.c b/disk-utils/mkfs.c index cf1a312d9..25cc59d20 100644 --- a/disk-utils/mkfs.c +++ b/disk-utils/mkfs.c @@ -38,8 +38,9 @@ #define DEFAULT_FSTYPE "ext2" #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] [-t ] [fs-options] []\n"), program_invocation_short_name); @@ -60,7 +61,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out) fprintf(out, USAGE_MAN_TAIL("mkfs(8)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } static void __attribute__ ((__noreturn__)) print_version(void) @@ -106,7 +107,7 @@ int main(int argc, char **argv) fstype = optarg; break; case 'h': - usage(stdout); + usage(); case VERSION_OPTION: print_version(); default: @@ -114,8 +115,10 @@ int main(int argc, char **argv) more = 1; break; /* start of specific arguments */ } - if (optind == argc) - usage(stderr); + if (optind == argc) { + warnx(_("no device specified")); + errtryhelp(EXIT_FAILURE); + } /* If -t wasn't specified, use the default */ if (fstype == NULL) -- cgit v1.2.3-55-g7522