Skip to content

Commit ab5ac78

Browse files
SukrutHerookarakpm00
authored andcommitted
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/[email protected] Fixes: aadc099 ("selftests/proc: add verbose mode for /proc/pid/maps tearing tests") Signed-off-by: Sukrut Heroorkar <[email protected]> Acked-by: Suren Baghdasaryan <[email protected]> Cc: David Hunter <[email protected]> Cc: Shuah Khan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent aa5a10b commit ab5ac78

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/testing/selftests/proc/proc-maps-race.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,11 @@ static void print_first_lines(char *text, int nr)
202202
int offs = end - text;
203203

204204
text[offs] = '\0';
205-
printf(text);
205+
printf("%s", text);
206206
text[offs] = '\n';
207207
printf("\n");
208208
} else {
209-
printf(text);
209+
printf("%s", text);
210210
}
211211
}
212212

@@ -221,7 +221,7 @@ static void print_last_lines(char *text, int nr)
221221
nr--;
222222
start--;
223223
}
224-
printf(start);
224+
printf("%s", start);
225225
}
226226

227227
static void print_boundaries(const char *title, FIXTURE_DATA(proc_maps_race) *self)

0 commit comments

Comments
 (0)