Skip to contentSkip to conversation

selftests/futex: Fix -Wformat-security warnings in futex_priv_hash

PATCH In review Sukrut Heroorkar 2 participants 3 messages Sep 5, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/futex: Fix -Wformat-security warnings in futex_priv_hash

Fix several -Wformat-security warnings in futex_priv_hash by passing the test message strings as arguments to %s format specifiers in ksft_*() logging functions.

This silences the warnings without changing the functional behavior of the test.

---
 .../selftests/futex/functional/futex_priv_hash.c       | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
tools/testing/selftests/futex/functional/futex_priv_hash.c +5 -5
index aea001ac4946..2627eeb1625f 100644
@@ -193,10 +193,10 @@ int main(int argc, char *argv[])
 	futex_slots1 = futex_hash_slots_get();
 	if (futex_slots1 <= 0) {
 		ksft_print_msg("Current hash buckets: %d\n", futex_slots1);
-		ksft_exit_fail_msg(test_msg_auto_create);
+		ksft_exit_fail_msg("%s", test_msg_auto_create);
 	}
 
-	ksft_test_result_pass(test_msg_auto_create);
+	ksft_test_result_pass("%s", test_msg_auto_create);
 
 	online_cpus = sysconf(_SC_NPROCESSORS_ONLN);
 	ret = pthread_barrier_init(&barrier_main, NULL, MAX_THREADS + 1);
@@ -237,11 +237,11 @@ int main(int argc, char *argv[])
 			}
 			ksft_print_msg("Expected increase of hash buckets but got: %d -> %d\n",
 				       futex_slots1, futex_slotsn);
-			ksft_exit_fail_msg(test_msg_auto_inc);
+			ksft_exit_fail_msg("%s", test_msg_auto_inc);
 		}
-		ksft_test_result_pass(test_msg_auto_inc);
+		ksft_test_result_pass("%s", test_msg_auto_inc);
 	} else {
-		ksft_test_result_skip(test_msg_auto_inc);
+		ksft_test_result_skip("%s", test_msg_auto_inc);
 	}
 	ret = pthread_mutex_unlock(&global_lock);
 
Signature · 1 line
2.43.0
#1 lore raw

Hi Sukrut,

Em 05/09/2025 12:17, Sukrut Heroorkar escreveu:

Quoted 8 lines

Fix several -Wformat-security warnings in futex_priv_hash by passing the test message strings as arguments to %s format specifiers in ksft_*() logging functions.

This silences the warnings without changing the functional behavior of the test.

This is already fixed upstream:

https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=locking/futex&id=f8ef9c24029c85cd0328a9c668283017d8c292ad

https://lore.kernel.org/all/[email protected]/

Thanks,
André

#2 lore raw

Hi André,

Quoted 12 lines · André Almeida

Hi Sukrut,

Em 05/09/2025 12:17, Sukrut Heroorkar escreveu:

Quoted 8 lines

Fix several -Wformat-security warnings in futex_priv_hash by passing the test message strings as arguments to %s format specifiers in ksft_*() logging functions.

This silences the warnings without changing the functional behavior of the test.

Quoted 8 lines

This is already fixed upstream:

https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=locking/futex&id=f8ef9c24029c85cd0328a9c668283017d8c292ad

https://lore.kernel.org/all/[email protected]/

Thanks,
André

Thanks for pointing this out.