Skip to content

Commit b476c93

Browse files
0x7f454c46Paolo Abeni
authored and
Paolo Abeni
committed
selftests/tcp_ao: Printing fixes to confirm with format-security
On my new laptop with packages from nixos-unstable, gcc 12.3.0 produces > lib/setup.c: In function ‘__test_msg’: > lib/setup.c:20:9: error: format not a string literal and no format arguments [-Werror=format-security] > 20 | ksft_print_msg(buf); > | ^~~~~~~~~~~~~~ > lib/setup.c: In function ‘__test_ok’: > lib/setup.c:26:9: error: format not a string literal and no format arguments [-Werror=format-security] > 26 | ksft_test_result_pass(buf); > | ^~~~~~~~~~~~~~~~~~~~~ > lib/setup.c: In function ‘__test_fail’: > lib/setup.c:32:9: error: format not a string literal and no format arguments [-Werror=format-security] > 32 | ksft_test_result_fail(buf); > | ^~~~~~~~~~~~~~~~~~~~~ > lib/setup.c: In function ‘__test_xfail’: > lib/setup.c:38:9: error: format not a string literal and no format arguments [-Werror=format-security] > 38 | ksft_test_result_xfail(buf); > | ^~~~~~~~~~~~~~~~~~~~~~ > lib/setup.c: In function ‘__test_error’: > lib/setup.c:44:9: error: format not a string literal and no format arguments [-Werror=format-security] > 44 | ksft_test_result_error(buf); > | ^~~~~~~~~~~~~~~~~~~~~~ > lib/setup.c: In function ‘__test_skip’: > lib/setup.c:50:9: error: format not a string literal and no format arguments [-Werror=format-security] > 50 | ksft_test_result_skip(buf); > | ^~~~~~~~~~~~~~~~~~~~~ > cc1: some warnings being treated as errors As the buffer was already pre-printed into, print it as a string rather than a format-string. Fixes: cfbab37 ("selftests/net: Add TCP-AO library") Signed-off-by: Dmitry Safonov <[email protected]> Reported-by: Muhammad Usama Anjum <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent beb78cd commit b476c93

File tree

1 file changed

+6
-6
lines changed
  • tools/testing/selftests/net/tcp_ao/lib

1 file changed

+6
-6
lines changed

tools/testing/selftests/net/tcp_ao/lib/setup.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,37 @@ static pthread_mutex_t ksft_print_lock = PTHREAD_MUTEX_INITIALIZER;
1717
void __test_msg(const char *buf)
1818
{
1919
pthread_mutex_lock(&ksft_print_lock);
20-
ksft_print_msg(buf);
20+
ksft_print_msg("%s", buf);
2121
pthread_mutex_unlock(&ksft_print_lock);
2222
}
2323
void __test_ok(const char *buf)
2424
{
2525
pthread_mutex_lock(&ksft_print_lock);
26-
ksft_test_result_pass(buf);
26+
ksft_test_result_pass("%s", buf);
2727
pthread_mutex_unlock(&ksft_print_lock);
2828
}
2929
void __test_fail(const char *buf)
3030
{
3131
pthread_mutex_lock(&ksft_print_lock);
32-
ksft_test_result_fail(buf);
32+
ksft_test_result_fail("%s", buf);
3333
pthread_mutex_unlock(&ksft_print_lock);
3434
}
3535
void __test_xfail(const char *buf)
3636
{
3737
pthread_mutex_lock(&ksft_print_lock);
38-
ksft_test_result_xfail(buf);
38+
ksft_test_result_xfail("%s", buf);
3939
pthread_mutex_unlock(&ksft_print_lock);
4040
}
4141
void __test_error(const char *buf)
4242
{
4343
pthread_mutex_lock(&ksft_print_lock);
44-
ksft_test_result_error(buf);
44+
ksft_test_result_error("%s", buf);
4545
pthread_mutex_unlock(&ksft_print_lock);
4646
}
4747
void __test_skip(const char *buf)
4848
{
4949
pthread_mutex_lock(&ksft_print_lock);
50-
ksft_test_result_skip(buf);
50+
ksft_test_result_skip("%s", buf);
5151
pthread_mutex_unlock(&ksft_print_lock);
5252
}
5353

0 commit comments

Comments
 (0)