|
|
09c1d0 |
From: Prarit Bhargava <prarit@redhat.com>
|
|
|
09c1d0 |
|
|
|
09c1d0 |
Subject: mcelog: Add --help option.
|
|
|
09c1d0 |
|
|
|
09c1d0 |
commit 91601566390676d3c590bbe4b680f4009b6caa22
|
|
|
09c1d0 |
Author: Prarit Bhargava <prarit@redhat.com>
|
|
|
09c1d0 |
Date: Thu Oct 12 13:35:33 2017 -0400
|
|
|
09c1d0 |
|
|
|
09c1d0 |
mcelog: Add --help option.
|
|
|
09c1d0 |
|
|
|
09c1d0 |
The mcelog man page states "See mcelog --help for a list of valid CPUs.".
|
|
|
09c1d0 |
This command returns 1 because --help is not a valid option.
|
|
|
09c1d0 |
|
|
|
09c1d0 |
Separate the exit(1) from the usage() function and add a --help option.
|
|
|
09c1d0 |
|
|
|
09c1d0 |
Signed-off-by: Prarit Bhargava <prarit@redhat.com>
|
|
|
09c1d0 |
Signed-off-by: Andi Kleen <ak@linux.intel.com>
|
|
|
09c1d0 |
|
|
|
09c1d0 |
diff --git a/mcelog.c b/mcelog.c
|
|
|
09c1d0 |
index 507f11bdbccb87cad45a2f182edd2a8146bd89f3..58a0aac26b53fa382567e034b2e2a8f25735e3aa 100644
|
|
|
09c1d0 |
--- a/mcelog.c
|
|
|
09c1d0 |
+++ b/mcelog.c
|
|
|
09c1d0 |
@@ -982,10 +982,10 @@ void usage(void)
|
|
|
09c1d0 |
"--pidfile file Write pid of daemon into file\n"
|
|
|
09c1d0 |
"--no-imc-log Disable extended iMC logging\n"
|
|
|
09c1d0 |
"--is-cpu-supported Exit with return code indicating whether the CPU is supported\n"
|
|
|
09c1d0 |
+"--help Display this message.\n"
|
|
|
09c1d0 |
);
|
|
|
09c1d0 |
printf("\n");
|
|
|
09c1d0 |
print_cputypes();
|
|
|
09c1d0 |
- exit(1);
|
|
|
09c1d0 |
}
|
|
|
09c1d0 |
|
|
|
09c1d0 |
enum options {
|
|
|
09c1d0 |
@@ -1017,6 +1017,7 @@ enum options {
|
|
|
09c1d0 |
O_DEBUG_NUMERRORS,
|
|
|
09c1d0 |
O_NO_IMC_LOG,
|
|
|
09c1d0 |
O_IS_CPU_SUPPORTED,
|
|
|
09c1d0 |
+ O_HELP,
|
|
|
09c1d0 |
};
|
|
|
09c1d0 |
|
|
|
09c1d0 |
static struct option options[] = {
|
|
|
09c1d0 |
@@ -1050,6 +1051,7 @@ static struct option options[] = {
|
|
|
09c1d0 |
{ "pidfile", 1, NULL, O_PIDFILE },
|
|
|
09c1d0 |
{ "debug-numerrors", 0, NULL, O_DEBUG_NUMERRORS }, /* undocumented: for testing */
|
|
|
09c1d0 |
{ "no-imc-log", 0, NULL, O_NO_IMC_LOG },
|
|
|
09c1d0 |
+ { "help", 0, NULL, O_HELP },
|
|
|
09c1d0 |
{ "is-cpu-supported", 0, NULL, O_IS_CPU_SUPPORTED },
|
|
|
09c1d0 |
{}
|
|
|
09c1d0 |
};
|
|
|
09c1d0 |
@@ -1080,12 +1082,15 @@ static int modifier(int opt)
|
|
|
09c1d0 |
break;
|
|
|
09c1d0 |
case O_INTEL_CPU: {
|
|
|
09c1d0 |
unsigned fam, mod;
|
|
|
09c1d0 |
- if (sscanf(optarg, "%i,%i", &fam, &mod) != 2)
|
|
|
09c1d0 |
+ if (sscanf(optarg, "%i,%i", &fam, &mod) != 2) {
|
|
|
09c1d0 |
usage();
|
|
|
09c1d0 |
+ exit(1);
|
|
|
09c1d0 |
+ }
|
|
|
09c1d0 |
cputype = select_intel_cputype(fam, mod);
|
|
|
09c1d0 |
if (cputype == CPU_GENERIC) {
|
|
|
09c1d0 |
fprintf(stderr, "Unknown Intel CPU\n");
|
|
|
09c1d0 |
usage();
|
|
|
09c1d0 |
+ exit(1);
|
|
|
09c1d0 |
}
|
|
|
09c1d0 |
cpu_forced = 1;
|
|
|
09c1d0 |
break;
|
|
|
09c1d0 |
@@ -1104,8 +1109,10 @@ static int modifier(int opt)
|
|
|
09c1d0 |
do_dmi = 0;
|
|
|
09c1d0 |
break;
|
|
|
09c1d0 |
case O_DMI_VERBOSE:
|
|
|
09c1d0 |
- if (sscanf(optarg, "%i", &v) != 1)
|
|
|
09c1d0 |
+ if (sscanf(optarg, "%i", &v) != 1) {
|
|
|
09c1d0 |
usage();
|
|
|
09c1d0 |
+ exit(1);
|
|
|
09c1d0 |
+ }
|
|
|
09c1d0 |
dmi_set_verbosity(v);
|
|
|
09c1d0 |
break;
|
|
|
09c1d0 |
case O_SYSLOG:
|
|
|
09c1d0 |
@@ -1117,8 +1124,10 @@ static int modifier(int opt)
|
|
|
09c1d0 |
break;
|
|
|
09c1d0 |
case O_CPUMHZ:
|
|
|
09c1d0 |
cpumhz_forced = 1;
|
|
|
09c1d0 |
- if (sscanf(optarg, "%lf", &cpumhz) != 1)
|
|
|
09c1d0 |
+ if (sscanf(optarg, "%lf", &cpumhz) != 1) {
|
|
|
09c1d0 |
usage();
|
|
|
09c1d0 |
+ exit(1);
|
|
|
09c1d0 |
+ }
|
|
|
09c1d0 |
break;
|
|
|
09c1d0 |
case O_SYSLOG_ERROR:
|
|
|
09c1d0 |
syslog_level = LOG_ERR;
|
|
|
09c1d0 |
@@ -1155,6 +1164,10 @@ static int modifier(int opt)
|
|
|
09c1d0 |
case O_IS_CPU_SUPPORTED:
|
|
|
09c1d0 |
check_only = 1;
|
|
|
09c1d0 |
break;
|
|
|
09c1d0 |
+ case O_HELP:
|
|
|
09c1d0 |
+ usage();
|
|
|
09c1d0 |
+ exit(0);
|
|
|
09c1d0 |
+ break;
|
|
|
09c1d0 |
case 0:
|
|
|
09c1d0 |
break;
|
|
|
09c1d0 |
default:
|
|
|
09c1d0 |
@@ -1184,8 +1197,10 @@ void argsleft(int ac, char **av)
|
|
|
09c1d0 |
int opt;
|
|
|
09c1d0 |
|
|
|
09c1d0 |
while ((opt = getopt_long(ac, av, "", options, NULL)) != -1) {
|
|
|
09c1d0 |
- if (modifier(opt) != 1)
|
|
|
09c1d0 |
+ if (modifier(opt) != 1) {
|
|
|
09c1d0 |
usage();
|
|
|
09c1d0 |
+ exit(1);
|
|
|
09c1d0 |
+ }
|
|
|
09c1d0 |
}
|
|
|
09c1d0 |
}
|
|
|
09c1d0 |
|
|
|
09c1d0 |
@@ -1284,16 +1299,20 @@ static void process(int fd, unsigned recordlen, unsigned loglen, char *buf)
|
|
|
09c1d0 |
|
|
|
09c1d0 |
static void noargs(int ac, char **av)
|
|
|
09c1d0 |
{
|
|
|
09c1d0 |
- if (getopt_long(ac, av, "", options, NULL) != -1)
|
|
|
09c1d0 |
+ if (getopt_long(ac, av, "", options, NULL) != -1) {
|
|
|
09c1d0 |
usage();
|
|
|
09c1d0 |
+ exit(1);
|
|
|
09c1d0 |
+ }
|
|
|
09c1d0 |
}
|
|
|
09c1d0 |
|
|
|
09c1d0 |
static void parse_config(char **av)
|
|
|
09c1d0 |
{
|
|
|
09c1d0 |
static const char config_fn[] = CONFIG_FILENAME;
|
|
|
09c1d0 |
const char *fn = config_file(av, config_fn);
|
|
|
09c1d0 |
- if (!fn)
|
|
|
09c1d0 |
+ if (!fn) {
|
|
|
09c1d0 |
usage();
|
|
|
09c1d0 |
+ exit(1);
|
|
|
09c1d0 |
+ }
|
|
|
09c1d0 |
if (parse_config_file(fn) < 0) {
|
|
|
09c1d0 |
/* If it's the default file don't complain if it isn't there */
|
|
|
09c1d0 |
if (fn != config_fn) {
|
|
|
09c1d0 |
@@ -1362,6 +1381,7 @@ int main(int ac, char **av)
|
|
|
09c1d0 |
while ((opt = getopt_long(ac, av, "", options, NULL)) != -1) {
|
|
|
09c1d0 |
if (opt == '?') {
|
|
|
09c1d0 |
usage();
|
|
|
09c1d0 |
+ exit(1);
|
|
|
09c1d0 |
} else if (combined_modifier(opt) > 0) {
|
|
|
09c1d0 |
continue;
|
|
|
09c1d0 |
} else if (opt == O_ASCII) {
|
|
|
09c1d0 |
@@ -1404,8 +1424,10 @@ int main(int ac, char **av)
|
|
|
09c1d0 |
modifier_finish();
|
|
|
09c1d0 |
if (av[optind])
|
|
|
09c1d0 |
logfn = av[optind++];
|
|
|
09c1d0 |
- if (av[optind])
|
|
|
09c1d0 |
+ if (av[optind]) {
|
|
|
09c1d0 |
usage();
|
|
|
09c1d0 |
+ exit(1);
|
|
|
09c1d0 |
+ }
|
|
|
09c1d0 |
checkdmi();
|
|
|
09c1d0 |
general_setup();
|
|
|
09c1d0 |
|