Skip to contentSkip to conversation

tools/latency-collector: fix -Wformat-security compile warns

PATCH In review Shuah Khan 2 participants 3 messages Apr 4, 2024 – May 21, 2024 Tracing

lore
Share & tools
lore

Shuah Khan

author
#0 lore raw

PATCH 1/1 tools/latency-collector: fix -Wformat-security compile warns

Fix the following -Wformat-security compile warnings adding missing format arguments:

latency-collector.c: In function ‘show_available’:
latency-collector.c:938:17: warning: format not a string literal and no format arguments [-Wformat-security]

  938 |                 warnx(no_tracer_msg);
      |                 ^~~~~

latency-collector.c:943:17: warning: format not a string literal and no format arguments [-Wformat-security]

  943 |                 warnx(no_latency_tr_msg);
      |                 ^~~~~

latency-collector.c: In function ‘find_default_tracer’:
latency-collector.c:986:25: warning: format not a string literal and no format arguments [-Wformat-security]

  986 |                         errx(EXIT_FAILURE, no_tracer_msg);
      |
                         ^~~~
latency-collector.c: In function ‘scan_arguments’:
latency-collector.c:1881:33: warning: format not a string literal and
no format arguments [-Wformat-security]
 1881 |                                 errx(EXIT_FAILURE, no_tracer_msg);
      |                                 ^~~~
---
 tools/tracing/latency/latency-collector.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/tracing/latency/latency-collector.c +4 -4
index 0fd9c747d396..cf263fe9deaf 100644
@@ -935,12 +935,12 @@ static void show_available(void)
 	}
 
 	if (!tracers) {
-		warnx(no_tracer_msg);
+		warnx("%s", no_tracer_msg);
 		return;
 	}
 
 	if (!found) {
-		warnx(no_latency_tr_msg);
+		warnx("%s", no_latency_tr_msg);
 		tracefs_list_free(tracers);
 		return;
 	}
@@ -983,7 +983,7 @@ static const char *find_default_tracer(void)
 	for (i = 0; relevant_tracers[i]; i++) {
 		valid = tracer_valid(relevant_tracers[i], &notracer);
 		if (notracer)
-			errx(EXIT_FAILURE, no_tracer_msg);
+			errx(EXIT_FAILURE, "%s", no_tracer_msg);
 		if (valid)
 			return relevant_tracers[i];
 	}
@@ -1878,7 +1878,7 @@ static void scan_arguments(int argc, char *argv[])
 			}
 			valid = tracer_valid(current_tracer, &notracer);
 			if (notracer)
-				errx(EXIT_FAILURE, no_tracer_msg);
+				errx(EXIT_FAILURE, "%s", no_tracer_msg);
 			if (!valid)
 				errx(EXIT_FAILURE,
 "The tracer %s is not supported by your kernel!\n", current_tracer);
Signature · 1 line
2.40.1
author
#1 lore raw
Quoted 60 lines · Shuah Khan

Fix the following -Wformat-security compile warnings adding missing format arguments:

latency-collector.c: In function ‘show_available’:
latency-collector.c:938:17: warning: format not a string literal and no format arguments [-Wformat-security]

   938 |                 warnx(no_tracer_msg);
       |                 ^~~~~

latency-collector.c:943:17: warning: format not a string literal and no format arguments [-Wformat-security]

   943 |                 warnx(no_latency_tr_msg);
       |                 ^~~~~

latency-collector.c: In function ‘find_default_tracer’:
latency-collector.c:986:25: warning: format not a string literal and no format arguments [-Wformat-security]

   986 |                         errx(EXIT_FAILURE, no_tracer_msg);
       |
                          ^~~~
latency-collector.c: In function ‘scan_arguments’:
latency-collector.c:1881:33: warning: format not a string literal and
no format arguments [-Wformat-security]
  1881 |                                 errx(EXIT_FAILURE, no_tracer_msg);
       |                                 ^~~~
---
  tools/tracing/latency/latency-collector.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
tools/tracing/latency/latency-collector.c +3 -3
index 0fd9c747d396..cf263fe9deaf 100644
@@ -935,12 +935,12 @@ static void show_available(void)
  	}
 
  	if (!tracers) {
-		warnx(no_tracer_msg);
+		warnx("%s", no_tracer_msg);
  		return;
  	}
 
  	if (!found) {
-		warnx(no_latency_tr_msg);
+		warnx("%s", no_latency_tr_msg);
  		tracefs_list_free(tracers);
  		return;
  	}
@@ -983,7 +983,7 @@ static const char *find_default_tracer(void)
  	for (i = 0; relevant_tracers[i]; i++) {
  		valid = tracer_valid(relevant_tracers[i], &notracer);
  		if (notracer)
-			errx(EXIT_FAILURE, no_tracer_msg);
+			errx(EXIT_FAILURE, "%s", no_tracer_msg);
  		if (valid)
  			return relevant_tracers[i];
  	}

tools/tracing/latency/latency-collector.c static void scan_arguments(int argc, char *argv[]) · line 1884

Quoted 8 lines
tools/tracing/latency/latency-collector.c +1 -1
@@ -1878,7 +1878,7 @@ static void scan_arguments(int argc, char *argv[])
  			}
  			valid = tracer_valid(current_tracer, &notracer);
  			if (notracer)
-				errx(EXIT_FAILURE, no_tracer_msg);
+				errx(EXIT_FAILURE, "%s", no_tracer_msg);
  			if (!valid)
  				errx(EXIT_FAILURE,
  "The tracer %s is not supported by your kernel!\n", current_tracer);

Any thoughts on this patch?

thanks,
-- Shuah

maintainer
#2 lore raw
Quoted 1 line · On Tue, 21 May 2024 09:11:08 -0600 Shuah Khan <[email protected]> wrote:

Any thoughts on this patch?

Sorry, this one fell through the cracks. Daniel Bristot has been maintaining his tools and I thought this was one of his changes.

I'll take a look at it.

-- Steve