From: Sasha Levin <sashal@kernel.org>
To: Christian Brauner <brauner@kernel.org>
Cc: Miklos Szeredi <mszeredi@redhat.com>,
Shuah Khan <shuah@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] selftests/statmount: fix format warnings on 32-bit and s390
Date: Tue, 3 Nov 2026 10:55:08 -0500 [thread overview]
Message-ID: <20261103155508.535010-1-sashal@kernel.org> (raw)
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
next reply other threads:[~2026-11-03 15:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 15:55 Sasha Levin [this message]
2026-11-05 21:56 ` [PATCH] selftests/statmount: fix format warnings on 32-bit and s390 Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261103155508.535010-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mszeredi@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.