cpumf/lscpumf.c: Check for help and version options first

Check command line arguments for help text and version
string first, before doing any action. This ensures this
information is always printed, even when invoked as non-root
user.

Fixes: https://github.com/ibm-s390-tools/s390-tools/issues/97
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Thomas Richter
2020-11-12 10:13:54 +01:00
committed by Jan Höppner
parent d619b492e9
commit 86685f001d

View File

@@ -3095,11 +3095,11 @@ int main(int argc, char **argv)
util_prg_init(&prg);
util_opt_init(opt_vec, NULL);
ret = read_info();
if (ret == EXIT_FAILURE)
return ret;
ret = parse_args(argc, argv);
if (read_info() == EXIT_FAILURE)
return EXIT_FAILURE;
switch ((ret = parse_args(argc, argv))) {
switch (ret) {
case ACTION_CNT:
case ACTION_CNTALL:
all = ret == ACTION_CNTALL;
@@ -3115,6 +3115,7 @@ int main(int argc, char **argv)
case ACTION_NONE:
case ACTION_INFO:
show_info(&cpumf, ret == ACTION_INFO);
ret = EXIT_SUCCESS;
break;
}
return ret;