Commit 4c687437 authored by John Kacur's avatar John Kacur Committed by Steven Rostedt (Google)

rtla: Fix exit status when returning from calls to usage()

rtla_usage(), osnoise_usage() and timerlat_usage() all exit with an
error status.

However when these are called from help, they should exit with a
non-error status.

Fix this by passing the exit status to the functions.

Note, although we remove the subsequent call to exit after calling
usage, we leave it in at the end of a function to suppress the compiler
warning "control reaches end of a non-void function".

Link: https://lkml.kernel.org/r/20221107144313.22470-1-jkacur@redhat.comSigned-off-by: default avatarJohn Kacur <jkacur@redhat.com>
Acked-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent 76dcd734
...@@ -903,7 +903,7 @@ struct osnoise_tool *osnoise_init_trace_tool(char *tracer) ...@@ -903,7 +903,7 @@ struct osnoise_tool *osnoise_init_trace_tool(char *tracer)
return NULL; return NULL;
} }
static void osnoise_usage(void) static void osnoise_usage(int err)
{ {
int i; int i;
...@@ -923,7 +923,7 @@ static void osnoise_usage(void) ...@@ -923,7 +923,7 @@ static void osnoise_usage(void)
for (i = 0; msg[i]; i++) for (i = 0; msg[i]; i++)
fprintf(stderr, "%s\n", msg[i]); fprintf(stderr, "%s\n", msg[i]);
exit(1); exit(err);
} }
int osnoise_main(int argc, char *argv[]) int osnoise_main(int argc, char *argv[])
...@@ -941,8 +941,7 @@ int osnoise_main(int argc, char *argv[]) ...@@ -941,8 +941,7 @@ int osnoise_main(int argc, char *argv[])
} }
if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) { if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) {
osnoise_usage(); osnoise_usage(0);
exit(0);
} else if (strncmp(argv[1], "-", 1) == 0) { } else if (strncmp(argv[1], "-", 1) == 0) {
/* the user skipped the tool, call the default one */ /* the user skipped the tool, call the default one */
osnoise_top_main(argc, argv); osnoise_top_main(argc, argv);
...@@ -956,6 +955,6 @@ int osnoise_main(int argc, char *argv[]) ...@@ -956,6 +955,6 @@ int osnoise_main(int argc, char *argv[])
} }
usage: usage:
osnoise_usage(); osnoise_usage(1);
exit(1); exit(1);
} }
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
/* /*
* rtla_usage - print rtla usage * rtla_usage - print rtla usage
*/ */
static void rtla_usage(void) static void rtla_usage(int err)
{ {
int i; int i;
...@@ -33,7 +33,7 @@ static void rtla_usage(void) ...@@ -33,7 +33,7 @@ static void rtla_usage(void)
for (i = 0; msg[i]; i++) for (i = 0; msg[i]; i++)
fprintf(stderr, "%s\n", msg[i]); fprintf(stderr, "%s\n", msg[i]);
exit(1); exit(err);
} }
/* /*
...@@ -70,11 +70,9 @@ int main(int argc, char *argv[]) ...@@ -70,11 +70,9 @@ int main(int argc, char *argv[])
goto usage; goto usage;
if (strcmp(argv[1], "-h") == 0) { if (strcmp(argv[1], "-h") == 0) {
rtla_usage(); rtla_usage(0);
exit(0);
} else if (strcmp(argv[1], "--help") == 0) { } else if (strcmp(argv[1], "--help") == 0) {
rtla_usage(); rtla_usage(0);
exit(0);
} }
retval = run_command(argc, argv, 1); retval = run_command(argc, argv, 1);
...@@ -82,6 +80,6 @@ int main(int argc, char *argv[]) ...@@ -82,6 +80,6 @@ int main(int argc, char *argv[])
exit(0); exit(0);
usage: usage:
rtla_usage(); rtla_usage(1);
exit(1); exit(1);
} }
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "timerlat.h" #include "timerlat.h"
static void timerlat_usage(void) static void timerlat_usage(int err)
{ {
int i; int i;
...@@ -34,7 +34,7 @@ static void timerlat_usage(void) ...@@ -34,7 +34,7 @@ static void timerlat_usage(void)
for (i = 0; msg[i]; i++) for (i = 0; msg[i]; i++)
fprintf(stderr, "%s\n", msg[i]); fprintf(stderr, "%s\n", msg[i]);
exit(1); exit(err);
} }
int timerlat_main(int argc, char *argv[]) int timerlat_main(int argc, char *argv[])
...@@ -52,8 +52,7 @@ int timerlat_main(int argc, char *argv[]) ...@@ -52,8 +52,7 @@ int timerlat_main(int argc, char *argv[])
} }
if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) { if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) {
timerlat_usage(); timerlat_usage(0);
exit(0);
} else if (strncmp(argv[1], "-", 1) == 0) { } else if (strncmp(argv[1], "-", 1) == 0) {
/* the user skipped the tool, call the default one */ /* the user skipped the tool, call the default one */
timerlat_top_main(argc, argv); timerlat_top_main(argc, argv);
...@@ -67,6 +66,6 @@ int timerlat_main(int argc, char *argv[]) ...@@ -67,6 +66,6 @@ int timerlat_main(int argc, char *argv[])
} }
usage: usage:
timerlat_usage(); timerlat_usage(1);
exit(1); exit(1);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment