Blame SOURCES/rtla-Fix-exit-status-when-returning-from-calls-to-usage.patch

e540bd
From 4c6874374859d89aa6a75019bb0a913369e472c9 Mon Sep 17 00:00:00 2001
e540bd
From: John Kacur <jkacur@redhat.com>
e540bd
Date: Mon, 7 Nov 2022 09:43:13 -0500
e540bd
Subject: [PATCH] rtla: Fix exit status when returning from calls to usage()
e540bd
e540bd
rtla_usage(), osnoise_usage() and timerlat_usage() all exit with an
e540bd
error status.
e540bd
e540bd
However when these are called from help, they should exit with a
e540bd
non-error status.
e540bd
e540bd
Fix this by passing the exit status to the functions.
e540bd
e540bd
Note, although we remove the subsequent call to exit after calling
e540bd
usage, we leave it in at the end of a function to suppress the compiler
e540bd
warning "control reaches end of a non-void function".
e540bd
e540bd
Link: https://lkml.kernel.org/r/20221107144313.22470-1-jkacur@redhat.com
e540bd
e540bd
Signed-off-by: John Kacur <jkacur@redhat.com>
e540bd
Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org>
e540bd
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
e540bd
---
e540bd
 src/osnoise.c  |  9 ++++-----
e540bd
 src/rtla.c     | 12 +++++-------
e540bd
 src/timerlat.c |  9 ++++-----
e540bd
 3 files changed, 13 insertions(+), 17 deletions(-)
e540bd
e540bd
diff --git a/src/osnoise.c b/src/osnoise.c
e540bd
index b8ec6c15bccb..4dee343909b1 100644
e540bd
--- a/src/osnoise.c
e540bd
+++ b/src/osnoise.c
e540bd
@@ -903,7 +903,7 @@ struct osnoise_tool *osnoise_init_trace_tool(char *tracer)
e540bd
 	return NULL;
e540bd
 }
e540bd
 
e540bd
-static void osnoise_usage(void)
e540bd
+static void osnoise_usage(int err)
e540bd
 {
e540bd
 	int i;
e540bd
 
e540bd
@@ -923,7 +923,7 @@ static void osnoise_usage(void)
e540bd
 
e540bd
 	for (i = 0; msg[i]; i++)
e540bd
 		fprintf(stderr, "%s\n", msg[i]);
e540bd
-	exit(1);
e540bd
+	exit(err);
e540bd
 }
e540bd
 
e540bd
 int osnoise_main(int argc, char *argv[])
e540bd
@@ -941,8 +941,7 @@ int osnoise_main(int argc, char *argv[])
e540bd
 	}
e540bd
 
e540bd
 	if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) {
e540bd
-		osnoise_usage();
e540bd
-		exit(0);
e540bd
+		osnoise_usage(0);
e540bd
 	} else if (strncmp(argv[1], "-", 1) == 0) {
e540bd
 		/* the user skipped the tool, call the default one */
e540bd
 		osnoise_top_main(argc, argv);
e540bd
@@ -956,6 +955,6 @@ int osnoise_main(int argc, char *argv[])
e540bd
 	}
e540bd
 
e540bd
 usage:
e540bd
-	osnoise_usage();
e540bd
+	osnoise_usage(1);
e540bd
 	exit(1);
e540bd
 }
e540bd
diff --git a/src/rtla.c b/src/rtla.c
e540bd
index 09bd21b8af81..52e8f1825281 100644
e540bd
--- a/src/rtla.c
e540bd
+++ b/src/rtla.c
e540bd
@@ -14,7 +14,7 @@
e540bd
 /*
e540bd
  * rtla_usage - print rtla usage
e540bd
  */
e540bd
-static void rtla_usage(void)
e540bd
+static void rtla_usage(int err)
e540bd
 {
e540bd
 	int i;
e540bd
 
e540bd
@@ -33,7 +33,7 @@ static void rtla_usage(void)
e540bd
 
e540bd
 	for (i = 0; msg[i]; i++)
e540bd
 		fprintf(stderr, "%s\n", msg[i]);
e540bd
-	exit(1);
e540bd
+	exit(err);
e540bd
 }
e540bd
 
e540bd
 /*
e540bd
@@ -70,11 +70,9 @@ int main(int argc, char *argv[])
e540bd
 		goto usage;
e540bd
 
e540bd
 	if (strcmp(argv[1], "-h") == 0) {
e540bd
-		rtla_usage();
e540bd
-		exit(0);
e540bd
+		rtla_usage(0);
e540bd
 	} else if (strcmp(argv[1], "--help") == 0) {
e540bd
-		rtla_usage();
e540bd
-		exit(0);
e540bd
+		rtla_usage(0);
e540bd
 	}
e540bd
 
e540bd
 	retval = run_command(argc, argv, 1);
e540bd
@@ -82,6 +80,6 @@ int main(int argc, char *argv[])
e540bd
 		exit(0);
e540bd
 
e540bd
 usage:
e540bd
-	rtla_usage();
e540bd
+	rtla_usage(1);
e540bd
 	exit(1);
e540bd
 }
e540bd
diff --git a/src/timerlat.c b/src/timerlat.c
e540bd
index 97abbf494fee..21cdcc5c4a29 100644
e540bd
--- a/src/timerlat.c
e540bd
+++ b/src/timerlat.c
e540bd
@@ -14,7 +14,7 @@
e540bd
 
e540bd
 #include "timerlat.h"
e540bd
 
e540bd
-static void timerlat_usage(void)
e540bd
+static void timerlat_usage(int err)
e540bd
 {
e540bd
 	int i;
e540bd
 
e540bd
@@ -34,7 +34,7 @@ static void timerlat_usage(void)
e540bd
 
e540bd
 	for (i = 0; msg[i]; i++)
e540bd
 		fprintf(stderr, "%s\n", msg[i]);
e540bd
-	exit(1);
e540bd
+	exit(err);
e540bd
 }
e540bd
 
e540bd
 int timerlat_main(int argc, char *argv[])
e540bd
@@ -52,8 +52,7 @@ int timerlat_main(int argc, char *argv[])
e540bd
 	}
e540bd
 
e540bd
 	if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) {
e540bd
-		timerlat_usage();
e540bd
-		exit(0);
e540bd
+		timerlat_usage(0);
e540bd
 	} else if (strncmp(argv[1], "-", 1) == 0) {
e540bd
 		/* the user skipped the tool, call the default one */
e540bd
 		timerlat_top_main(argc, argv);
e540bd
@@ -67,6 +66,6 @@ int timerlat_main(int argc, char *argv[])
e540bd
 	}
e540bd
 
e540bd
 usage:
e540bd
-	timerlat_usage();
e540bd
+	timerlat_usage(1);
e540bd
 	exit(1);
e540bd
 }
e540bd
-- 
e540bd
2.39.0
e540bd