Skip to content

Commit 527c425

Browse files
author
Herton R. Krzesinski
committed
Merge: rtla: Fix exit status when returning from calls to usage()
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/1954 rtla: Fix exit status when returning from calls to usage() Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2160394 commit 88c21260b9cd7efabbc8c5fce1448c70fe0c4058 (HEAD -> bz2160394, jkacur/bz2160394) Author: John Kacur <jkacur@redhat.com> Date: Mon Nov 7 09:43:13 2022 -0500 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.com Signed-off-by: John Kacur <jkacur@redhat.com> Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: John Kacur <jkacur@redhat.com> Approved-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com> Approved-by: Eder Zulian <ezulian@redhat.com> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
2 parents f273d69 + 254e465 commit 527c425

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

tools/tracing/rtla/src/osnoise.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ struct osnoise_tool *osnoise_init_trace_tool(char *tracer)
903903
return NULL;
904904
}
905905

906-
static void osnoise_usage(void)
906+
static void osnoise_usage(int err)
907907
{
908908
int i;
909909

@@ -923,7 +923,7 @@ static void osnoise_usage(void)
923923

924924
for (i = 0; msg[i]; i++)
925925
fprintf(stderr, "%s\n", msg[i]);
926-
exit(1);
926+
exit(err);
927927
}
928928

929929
int osnoise_main(int argc, char *argv[])
@@ -941,8 +941,7 @@ int osnoise_main(int argc, char *argv[])
941941
}
942942

943943
if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) {
944-
osnoise_usage();
945-
exit(0);
944+
osnoise_usage(0);
946945
} else if (strncmp(argv[1], "-", 1) == 0) {
947946
/* the user skipped the tool, call the default one */
948947
osnoise_top_main(argc, argv);
@@ -956,6 +955,6 @@ int osnoise_main(int argc, char *argv[])
956955
}
957956

958957
usage:
959-
osnoise_usage();
958+
osnoise_usage(1);
960959
exit(1);
961960
}

tools/tracing/rtla/src/rtla.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/*
1515
* rtla_usage - print rtla usage
1616
*/
17-
static void rtla_usage(void)
17+
static void rtla_usage(int err)
1818
{
1919
int i;
2020

@@ -33,7 +33,7 @@ static void rtla_usage(void)
3333

3434
for (i = 0; msg[i]; i++)
3535
fprintf(stderr, "%s\n", msg[i]);
36-
exit(1);
36+
exit(err);
3737
}
3838

3939
/*
@@ -70,18 +70,16 @@ int main(int argc, char *argv[])
7070
goto usage;
7171

7272
if (strcmp(argv[1], "-h") == 0) {
73-
rtla_usage();
74-
exit(0);
73+
rtla_usage(0);
7574
} else if (strcmp(argv[1], "--help") == 0) {
76-
rtla_usage();
77-
exit(0);
75+
rtla_usage(0);
7876
}
7977

8078
retval = run_command(argc, argv, 1);
8179
if (retval)
8280
exit(0);
8381

8482
usage:
85-
rtla_usage();
83+
rtla_usage(1);
8684
exit(1);
8785
}

tools/tracing/rtla/src/timerlat.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include "timerlat.h"
1616

17-
static void timerlat_usage(void)
17+
static void timerlat_usage(int err)
1818
{
1919
int i;
2020

@@ -34,7 +34,7 @@ static void timerlat_usage(void)
3434

3535
for (i = 0; msg[i]; i++)
3636
fprintf(stderr, "%s\n", msg[i]);
37-
exit(1);
37+
exit(err);
3838
}
3939

4040
int timerlat_main(int argc, char *argv[])
@@ -52,8 +52,7 @@ int timerlat_main(int argc, char *argv[])
5252
}
5353

5454
if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) {
55-
timerlat_usage();
56-
exit(0);
55+
timerlat_usage(0);
5756
} else if (strncmp(argv[1], "-", 1) == 0) {
5857
/* the user skipped the tool, call the default one */
5958
timerlat_top_main(argc, argv);
@@ -67,6 +66,6 @@ int timerlat_main(int argc, char *argv[])
6766
}
6867

6968
usage:
70-
timerlat_usage();
69+
timerlat_usage(1);
7170
exit(1);
7271
}

0 commit comments

Comments
 (0)