selftests/harness: fix many "format string is empty" warnings
Subsystems (2)
PATCH 1/1 selftests/harness: fix many "format string is empty" warnings
In order to build with clang at all, in order to see these symptoms, one must first apply Valentin Obst's build fix for LLVM [1]. Once that is done, then when building with clang, via:
make LLVM=1 -C tools/testing/selftests
...clang emits a "format string is empty" warning. (gcc also emits a similar warning.)
Fix by passing NULL, instead of "", for the msg argument to ksft_test_result_code(). This removes dozens of warnings and a few errors (some tests have -Werror set).
[1] https://lore.kernel.org/all/20240329-selftests-libmk-llvm-rfc-v1-1-2f9ed7d1c49f@valentinobst.de/
--- tools/testing/selftests/kselftest_harness.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/testing/selftests/kselftest_harness.h +4 -2
@@ -1207,8 +1207,10 @@ void __run_test(struct __fixture_metadata *f,else diagnostic ="unknown" ; -ksft_test_result_code (t->exit_code, test_name, - diagnostic ?"%s" :NULL , diagnostic); +if (diagnostic) +ksft_test_result_code (t->exit_code, test_name,"%s" , diagnostic); +else +ksft_test_result_code (t->exit_code, test_name,NULL );free (test_name); }
base-commit: 18daea77cca626f590fb140fc11e3a43c5d41354
prerequisite-patch-id: b901ece2a5b78503e2fb5480f20e304d36a0ea27
Signature · 1 line
2.45.0
Hi John,
Quoted 8 lines · John Hubbard
In order to build with clang at all, in order to see these symptoms, one must first apply Valentin Obst's build fix for LLVM [1]. Once that is done, then when building with clang, via:
make LLVM=1 -C
tools/testing/selftests...clang emits a "format string is empty" warning. (gcc also emits a similar warning.)
The warning you are describing here sounds like the same exact one that commit caed8eba2215 ("selftests: kselftest_harness: fix Clang warning about zero-length format") should have addressed in 6.9-rc5. Is this patch actually necessary?
Quoted 1 line
Fix by passing NULL, instead of "", for the msg argument to
Because this text is describing what was done in caed8eba2215...
Quoted 22 lines
ksft_test_result_code(). This removes dozens of warnings and a few errors (some tests have -Werror set).[1] https://lore.kernel.org/all/20240329-selftests-libmk-llvm-rfc-v1-1-2f9ed7d1c49f@valentinobst.de/
Cc Valentin Obst <[email protected]>Cc Kees Cook <[email protected]>Cc Nick Desaulniers <[email protected]>Cc Nathan Chancellor <[email protected]>Cc Shuah Khan <[email protected]>Cc Justin Stitt <[email protected]>Cc Bill Wendling <[email protected]>Signed-off-by John Hubbard <[email protected]>--- tools/testing/selftests/kselftest_harness.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)tools/testing/selftests/kselftest_harness.h +0
-0
tools/testing/selftests/kselftest_harness.h void __run_test(struct __fixture_metadata *f, · line 1213
Quoted 9 lines
tools/testing/selftests/kselftest_harness.h +4
-2@@ -1207,8 +1207,10 @@ void __run_test(struct __fixture_metadata *f,else diagnostic ="unknown" ; -ksft_test_result_code (t->exit_code, test_name, - diagnostic ?"%s" :NULL , diagnostic); +if (diagnostic) +ksft_test_result_code (t->exit_code, test_name,"%s" , diagnostic); +else +ksft_test_result_code (t->exit_code, test_name,NULL );
but this diff is not doing that because it is based on a tree that has caed8eba2215; instead, it appears to be a completely identical transformation?
Cheers,
Nathan
Quoted 9 lines
tools/testing/selftests/kselftest_harness.h +0
-0free (test_name); }base-commit:
18daea77cca626f590fb140fc11e3a43c5d41354
prerequisite-patch-id:b901ece2a5b78503e2fb5480f20e304d36a0ea27Signature · 1 line
2.45.0
Quoted 9 lines · Nathan Chancellor
Hi John,
Quoted 6 lines · John Hubbard
In order to build with clang at all, in order to see these symptoms, one must first apply Valentin Obst's build fix for LLVM [1]. Once that is done, then when building with clang, via:
make LLVM=1 -C
tools/testing/selftests
Quoted 7 lines
Quoted 2 lines
...clang emits a "format string is empty" warning. (gcc also emits a similar warning.)
The warning you are describing here sounds like the same exact one that commit
caed8eba2215("selftests:kselftest_harness: fix Clang warning about zero-length format") should have addressed in 6.9-rc5. Is this patch actually necessary?
Apparently not!
Quoted 4 lines
Quoted 2 lines
Fix by passing NULL, instead of "", for the msg argument to
Because this text is describing what was done in
caed8eba2215...
Yes. I took a while between discovering the issue, and posting a fix, I think that's why.
Quoted 26 lines
Quoted 26 lines
ksft_test_result_code(). This removes dozens of warnings and a few errors (some tests have -Werror set).[1] https://lore.kernel.org/all/20240329-selftests-libmk-llvm-rfc-v1-1-2f9ed7d1c49f@valentinobst.de/
Cc Valentin Obst <[email protected]>Cc Kees Cook <[email protected]>Cc Nick Desaulniers <[email protected]>Cc Nathan Chancellor <[email protected]>Cc Shuah Khan <[email protected]>Cc Justin Stitt <[email protected]>Cc Bill Wendling <[email protected]>Signed-off-by John Hubbard <[email protected]>--- tools/testing/selftests/kselftest_harness.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)tools/testing/selftests/kselftest_harness.h +0
-0@@ -1207,8 +1207,10 @@ void __run_test(struct __fixture_metadata *f,else diagnostic ="unknown" ;
Quoted 11 lines
tools/testing/selftests/kselftest_harness.h void __run_test(struct __fixture_metadata *f, · line 1213
Quoted 6 lines
tools/testing/selftests/kselftest_harness.h +4
-2-ksft_test_result_code (t->exit_code, test_name, - diagnostic ?"%s" :NULL , diagnostic); +if (diagnostic) +ksft_test_result_code (t->exit_code, test_name,"%s" , diagnostic); +else +ksft_test_result_code (t->exit_code, test_name,NULL );but this diff is not doing that because it is based on a tree that has
caed8eba2215; instead, it appears to be a completely identical transformation?
It's nice to see that someone else had the same fix, anyway. Sorry about the noise, and yes let's please just drop this one.
thanks,
Signature · 2 lines
John Hubbard NVIDIA