Skip to contentSkip to conversation

rt-tests: oslat: print version string

PATCH In review John Kacur 3 participants 5 messages Feb 11, 2021

lore
Share & tools
lore

John Kacur

author
#0 lore raw

PATCH 1/1 rt-tests: oslat: print version string

During the streamlining of the command line options something went awry with the version. The author of oslat wishes to always print the version string. This allows us to just exit in the case of -v

Fixes e411219d27b1

---
 src/oslat/oslat.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
src/oslat/oslat.c +3 -4
index 5b7e0d5b5d5c..7826c277f26d 100644
@@ -512,7 +512,6 @@ static void handle_alarm(int code)
 
 static void usage(int error)
 {
-	printf("oslat V %1.2f\n", VERSION);
 	printf("Usage:\n"
 	       "oslat <options>\n\n"
 	       "This is an OS latency detector by running busy loops on specified cores.\n"
@@ -657,8 +656,8 @@ static void parse_options(int argc, char *argv[])
 			break;
 		case 'v':
 			/*
-			 * Because we always dump the version even before parsing options,
-			 * what we need to do is to quit..
+			 * We always print the version before parsing options
+			 * so just exit
 			 */
 			exit(0);
 			break;
@@ -736,7 +735,7 @@ int main(int argc, char *argv[])
 	g.workload_mem_size = WORKLOAD_MEM_SIZE;
 	/* Run the main thread on cpu0 by default */
 	g.cpu_main_thread = 0;
-
+	printf("oslat V %1.2f\n", VERSION);
 	parse_options(argc, argv);
 
 	TEST(mlockall(MCL_CURRENT | MCL_FUTURE) == 0);
Signature · 1 line
2.26.2
#1 lore raw

src/oslat/oslat.c static void handle_alarm(int code) · line 515

Quoted 8 lines
src/oslat/oslat.c +0 -1
@@ -512,7 +512,6 @@ static void handle_alarm(int code)
 
 static void usage(int error)
 {
-	printf("oslat V %1.2f\n", VERSION);
 	printf("Usage:\n"

Why do you remove the version string in the usage output. Every other tool prints it?

author
#2 lore raw
Quoted 4 lines · Daniel Wagner
Quoted 4 lines
src/oslat/oslat.c +0 -0
@@ -512,7 +512,6 @@ static void handle_alarm(int code)
 
Quoted 9 lines

src/oslat/oslat.c static void handle_alarm(int code) · line 515

Quoted 4 lines
src/oslat/oslat.c +0 -1
 static void usage(int error)
 {
-	printf("oslat V %1.2f\n", VERSION);
 	printf("Usage:\n"

Why do you remove the version string in the usage output. Every other tool prints it?

Because the version is printed out before the call to parse the options. If you don't remove it here, it gets printed out twice.

John

#3 lore raw
Quoted 2 lines · John Kacur

Because the version is printed out before the call to parse the options. If you don't remove it here, it gets printed out twice.

Ah, that makes sense.

Reviewed-by on v1 1/1
#4 lore raw
In reply to John Kacur
Quoted 3 lines · John Kacur

During the streamlining of the command line options something went awry with the version. The author of oslat wishes to always print the version string. This allows us to just exit in the case of -v

Thanks. It's just that if we need to recover "-v" behavior it's simply to just add that print() back, imho. Sorry if I seemed to have made that request "stronger". :)

Quoted 7 lines

Fixes e411219d27b1

Signature · 1 line
Peter Xu