summaryrefslogtreecommitdiffstats
path: root/sys-utils/lscpu.c
diff options
context:
space:
mode:
authorKarel Zak2011-02-08 15:36:28 +0100
committerKarel Zak2011-02-08 15:36:28 +0100
commit39561c706a2417ab465275cef0f94d63493d1604 (patch)
tree6256fa2955f4cea8c13d7db0ad37fcdb64635bc6 /sys-utils/lscpu.c
parentuuidd: correctly report number of generated subsequent UUIDs (diff)
downloadkernel-qcow2-util-linux-39561c706a2417ab465275cef0f94d63493d1604.tar.gz
kernel-qcow2-util-linux-39561c706a2417ab465275cef0f94d63493d1604.tar.xz
kernel-qcow2-util-linux-39561c706a2417ab465275cef0f94d63493d1604.zip
lscpu: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/lscpu.c')
-rw-r--r--sys-utils/lscpu.c14
1 files changed, 8 insertions, 6 deletions
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 <unistd.h>
#include <stdarg.h>
#include <bitops.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#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);
}
}