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

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