mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] selftests/statmount: fix format warnings on 32-bit and s390
@ 2026-11-03 15:55 Sasha Levin
  0 siblings, 0 replies; only message in thread
From: Sasha Levin @ 2026-11-03 15:55 UTC (permalink / raw)
  To: Christian Brauner
  Cc: Miklos Szeredi, Shuah Khan, linux-fsdevel, linux-kselftest, linux-kernel

The f_type field of struct statfs is an int on i386 and armhf and an
unsigned int on s390x, and the listmount() results are uint64_t, so
printing them with %lx and %zi warns:

  statmount_test_ns.c:243:56: warning: format '%zi' expects argument of type 'signed size_t', but argument 2 has type 'uint64_t' {aka 'long long unsigned int'} [-Wformat=]

Cast f_type to unsigned long, and print the listmount() results as
unsigned long long.

On i386 and armhf the comparison next to it also sign-extends f_type to
the 64-bit sb_magic, so a file system with the top bit set in its magic,
such as btrfs, fails the test. Compare against the same cast.

Signed-off-by: Sasha Levin <sashal@kernel.org>
---
Found with a 32-bit build of the selftests with a 64-bit time_t (gcc 16
and clang 21 with -m32 -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64);
KernelCI's 32-bit arm and s390 builds show the same warnings. The
changed files build without format warnings in the 32-bit builds now,
and the x86_64 builds don't change. The other selftests get the same
kind of fix in separate patches.

 .../testing/selftests/filesystems/statmount/statmount_test.c | 4 ++--
 .../selftests/filesystems/statmount/statmount_test_ns.c      | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/filesystems/statmount/statmount_test.c b/tools/testing/selftests/filesystems/statmount/statmount_test.c
index b237a95ec9fb3..8133a5841ac08 100644
--- a/tools/testing/selftests/filesystems/statmount/statmount_test.c
+++ b/tools/testing/selftests/filesystems/statmount/statmount_test.c
@@ -335,10 +335,10 @@ static void test_statmount_sb_basic(void)
 		return;
 	}
 
-	if (sm.sb_magic != sf.f_type) {
+	if (sm.sb_magic != (unsigned long)sf.f_type) {
 		ksft_test_result_fail("unexpected sb magic: 0x%llx != 0x%lx\n",
 				      (unsigned long long) sm.sb_magic,
-				      sf.f_type);
+				      (unsigned long) sf.f_type);
 		return;
 	}
 
diff --git a/tools/testing/selftests/filesystems/statmount/statmount_test_ns.c b/tools/testing/selftests/filesystems/statmount/statmount_test_ns.c
index e500905e4c078..c9ef755ffaa72 100644
--- a/tools/testing/selftests/filesystems/statmount/statmount_test_ns.c
+++ b/tools/testing/selftests/filesystems/statmount/statmount_test_ns.c
@@ -240,8 +240,9 @@ static int validate_external_listmount(pid_t pid, uint64_t child_nr_mounts)
 	}
 
 	if (nr_mounts != child_nr_mounts) {
-		ksft_print_msg("listmount results is %zi != %zi\n", nr_mounts,
-			       child_nr_mounts);
+		ksft_print_msg("listmount results is %llu != %llu\n",
+			       (unsigned long long)nr_mounts,
+			       (unsigned long long)child_nr_mounts);
 		return NSID_FAIL;
 	}
 
-- 
2.53.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-03 15:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 15:55 [PATCH] selftests/statmount: fix format warnings on 32-bit and s390 Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®