Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/proc: fix string literal warning in proc-maps-race.c

This change resolves non literal string format warning invoked for
proc-maps-race.c while compiling.

proc-maps-race.c:205:17: warning: format not a string literal and no format arguments [-Wformat-security]
205 | printf(text);
| ^~~~~~
proc-maps-race.c:209:17: warning: format not a string literal and no format arguments [-Wformat-security]
209 | printf(text);
| ^~~~~~
proc-maps-race.c: In function `print_last_lines':
proc-maps-race.c:224:9: warning: format not a string literal and no format arguments [-Wformat-security]
224 | printf(start);
| ^~~~~~

Add string format specifier %s for the printf calls in both
print_first_lines() and print_last_lines() thus resolving the warnings.

The test executes fine after this change thus causing no effect to the
functional behavior of the test.

Link: https://lkml.kernel.org/r/20250804225633.841777-1-hsukrut3@gmail.com
Fixes: aadc099c480f ("selftests/proc: add verbose mode for /proc/pid/maps tearing tests")
Signed-off-by: Sukrut Heroorkar <hsukrut3@gmail.com>
Acked-by: Suren Baghdasaryan <surenb@google.com>
Cc: David Hunter <david.hunter.linux@gmail.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Sukrut Heroorkar and committed by
Andrew Morton
ab5ac789 aa5a10b0

+3 -3
+3 -3
tools/testing/selftests/proc/proc-maps-race.c
··· 202 202 int offs = end - text; 203 203 204 204 text[offs] = '\0'; 205 - printf(text); 205 + printf("%s", text); 206 206 text[offs] = '\n'; 207 207 printf("\n"); 208 208 } else { 209 - printf(text); 209 + printf("%s", text); 210 210 } 211 211 } 212 212 ··· 221 221 nr--; 222 222 start--; 223 223 } 224 - printf(start); 224 + printf("%s", start); 225 225 } 226 226 227 227 static void print_boundaries(const char *title, FIXTURE_DATA(proc_maps_race) *self)