From 39561c706a2417ab465275cef0f94d63493d1604 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 8 Feb 2011 15:36:28 +0100 Subject: lscpu: cleanup usage() Signed-off-by: Karel Zak --- sys-utils/lscpu.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'sys-utils/lscpu.c') diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index 66f6126f0..d59d2e231 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include "cpuset.h" #include "nls.h" @@ -911,18 +913,18 @@ print_readable(struct lscpu_desc *desc, int hex) } } -void usage(int rc) +static void __attribute__((__noreturn__)) usage(FILE *out) { - printf(_("Usage: %s [option]\n"), + fprintf(out, _("Usage: %s [option]\n"), program_invocation_short_name); - puts(_( "CPU architecture information helper\n\n" + fprintf(out,_("CPU architecture information helper\n\n" " -h, --help usage information\n" " -p, --parse print out in parsable instead of printable format.\n" " -s, --sysroot use the directory as a new system root.\n" " -x, --hex print haxadecimal masks rather than lists of CPU(s)\n")); - exit(rc); + exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); } int main(int argc, char *argv[]) @@ -945,7 +947,7 @@ int main(int argc, char *argv[]) while((c = getopt_long(argc, argv, "hps:x", longopts, NULL)) != -1) { switch (c) { case 'h': - usage(EXIT_SUCCESS); + usage(stdout); case 'p': parsable = 1; break; @@ -958,7 +960,7 @@ int main(int argc, char *argv[]) hex = 1; break; default: - usage(EXIT_FAILURE); + usage(stderr); } } -- cgit v1.2.3-55-g7522