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/swapoff.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'sys-utils/swapoff.c') diff --git a/sys-utils/swapoff.c b/sys-utils/swapoff.c index aab6dfb8d..da2e268d7 100644 --- a/sys-utils/swapoff.c +++ b/sys-utils/swapoff.c @@ -116,8 +116,9 @@ static int swapoff_by(const char *name, const char *value, int quiet) return special ? do_swapoff(special, quiet, CANONIC) : cannot_find(value); } -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); @@ -141,7 +142,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out) " name of file to be used\n"), out); fprintf(out, USAGE_MAN_TAIL("swapoff(8)")); - exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } static int swapoff_all(void) @@ -207,7 +208,7 @@ int main(int argc, char *argv[]) ++all; break; case 'h': /* help */ - usage(stdout); + usage(); break; case 'v': /* be chatty */ ++verbose; @@ -227,8 +228,10 @@ int main(int argc, char *argv[]) } argv += optind; - if (!all && !numof_labels() && !numof_uuids() && *argv == NULL) - usage(stderr); + if (!all && !numof_labels() && !numof_uuids() && *argv == NULL) { + warnx(_("bad usage")); + errtryhelp(EXIT_FAILURE); + } mnt_init_debug(0); mntcache = mnt_new_cache(); -- cgit v1.2.3-55-g7522