* [PATCH] selftests/statmount: fix format warnings on 32-bit and s390
@ 2026-11-03 15:55 Sasha Levin
2026-11-05 21:56 ` Christian Brauner
0 siblings, 1 reply; 2+ messages 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 related [flat|nested] 2+ messages in thread* Re: [PATCH] selftests/statmount: fix format warnings on 32-bit and s390
2026-11-03 15:55 [PATCH] selftests/statmount: fix format warnings on 32-bit and s390 Sasha Levin
@ 2026-11-05 21:56 ` Christian Brauner
0 siblings, 0 replies; 2+ messages in thread
From: Christian Brauner @ 2026-11-05 21:56 UTC (permalink / raw)
To: Sasha Levin
Cc: Miklos Szeredi, Shuah Khan, linux-fsdevel, linux-kselftest,
linux-kernel
On Tue, 03 Nov 2026 10:55:08 -0500, Sasha Levin wrote:
> 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.
>
> [...]
Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes
[1/1] selftests/statmount: fix format warnings on 32-bit and s390
https://git.kernel.org/vfs/vfs/c/de48f2a93e4f
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-05 21:56 UTC | newest]
Thread overview: 2+ messages (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
2026-11-05 21:56 ` Christian Brauner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.