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

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