From: David Laight <david.laight.linux@gmail.com>
To: Sasha Levin <sashal@kernel.org>
Cc: Christian Brauner <brauner@kernel.org>,
Shuah Khan <shuah@kernel.org>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH] selftests/pidfd: print time_t as long long
Date: Wed, 18 Nov 2026 13:22:39 +0000 [thread overview]
Message-ID: <20261118132239.600873a8@pumpkin> (raw)
In-Reply-To: <20261103155447.534264-1-sashal@kernel.org>
On Tue, 3 Nov 2026 10:54:47 -0500
Sasha Levin <sashal@kernel.org> wrote:
> On 32-bit architectures with a 64-bit time_t, such as armhf in Debian
> 13, printing the time_t values with %lu warns:
>
> pidfd_test.c:523:50: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'time_t' {aka 'long long int'} [-Wformat=]
>
> Cast them to long long and print them with %lld.
>
> 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 builds show the same warnings. The changed files
> build without format warnings there now, and the x86_64 builds don't
> change. The other selftests get the same kind of fix in separate
> patches.
>
> tools/testing/selftests/pidfd/pidfd_test.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/pidfd/pidfd_test.c b/tools/testing/selftests/pidfd/pidfd_test.c
> index 932cbd8caa770..a53e72cb256ce 100644
> --- a/tools/testing/selftests/pidfd/pidfd_test.c
> +++ b/tools/testing/selftests/pidfd/pidfd_test.c
> @@ -520,7 +520,7 @@ static void test_pidfd_poll_exec(int use_waitpid)
>
> time_t prog_time = time(NULL) - prog_start;
Why not just change the type to 'unsigned int' and use "%u" ?
It isn't as though the difference is going to be longer than 75 years.
David
>
> - ksft_print_msg("Time waited for child: %lu\n", prog_time);
> + ksft_print_msg("Time waited for child: %lld\n", (long long)prog_time);
>
> close(pidfd);
>
> @@ -599,7 +599,8 @@ static void test_pidfd_poll_leader_exit(int use_waitpid)
>
> time_t since_child_exit = time(NULL) - *child_exit_secs;
>
> - ksft_print_msg("Time since child exit: %lu\n", since_child_exit);
> + ksft_print_msg("Time since child exit: %lld\n",
> + (long long)since_child_exit);
>
> close(pidfd);
>
prev parent reply other threads:[~2026-11-18 13:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 15:54 Sasha Levin
2026-11-18 12:12 ` Christian Brauner
2026-11-18 13:22 ` David Laight [this message]
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=20261118132239.600873a8@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=brauner@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=sashal@kernel.org \
--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 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®