[PATCH] selftests/namespaces: initialize the byte the children write

From: Sasha Levin

Date: Tue Nov 03 2026 - 12:23:46 EST


The children in listns_pagination_bug and stress_test write c to the
parent only to say they are ready, but never set it, and clang 21
warns:

stress_test.c:137:22: warning: variable 'c' is uninitialized when passed as a const pointer argument here [-Wuninitialized-const-pointer]

Initialize it to 'X', as the parent does with its byte.

Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
Found with clang 21. The namespaces tests aren't in TARGETS in
tools/testing/selftests/Makefile, so CI doesn't build or run them. Is
that on purpose?

tools/testing/selftests/namespaces/listns_pagination_bug.c | 2 +-
tools/testing/selftests/namespaces/stress_test.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/namespaces/listns_pagination_bug.c b/tools/testing/selftests/namespaces/listns_pagination_bug.c
index da7d33f963972..6452825e88506 100644
--- a/tools/testing/selftests/namespaces/listns_pagination_bug.c
+++ b/tools/testing/selftests/namespaces/listns_pagination_bug.c
@@ -46,7 +46,7 @@ TEST(pagination_with_type_filter)
ASSERT_GE(pids[i], 0);

if (pids[i] == 0) {
- char c;
+ char c = 'X';
close(sv[0]);

if (setup_userns() < 0) {
diff --git a/tools/testing/selftests/namespaces/stress_test.c b/tools/testing/selftests/namespaces/stress_test.c
index dd7df7d6cb277..6a27b98c5bc2a 100644
--- a/tools/testing/selftests/namespaces/stress_test.c
+++ b/tools/testing/selftests/namespaces/stress_test.c
@@ -124,7 +124,7 @@ TEST(many_concurrent_namespaces)

if (pids[i] == 0) {
/* Child: create user namespace and wait for parent signal */
- char c;
+ char c = 'X';

close(sv[0]);

@@ -366,7 +366,7 @@ TEST(listns_pagination_stress)
ASSERT_GE(pids[i], 0);

if (pids[i] == 0) {
- char c;
+ char c = 'X';
close(sv[0]);

if (setup_userns() < 0) {
--
2.53.0