Thread View: linux.kernel.netdev
4 messages
4 total messages
Started by Sasha Levin
Tue, 03 Nov 2026 15:55
[PATCH] selftests: net: fix format warnings on 32-bit architectures
Author: Sasha Levin
Date: Tue, 03 Nov 2026 15:55
Date: Tue, 03 Nov 2026 15:55
76 lines
10683 bytes
10683 bytes
On 32-bit architectures ssize_t is an int, tv_sec is a long long with a
64-bit time_t, and uint64_t is not a size_t, so ipsec, txtimestamp and
the tcp_ao library warn when printing them with %ld, %lu and %zu:
txtimestamp.c:191:42: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type '__time64_t' {aka 'long long int'} [-Wformat=]
Print ssize_t with %zd, tv_sec as long long, and the net namespace
cookies with PRIu64 as the rest of ftrace-tcp.c already does. While at
it, print tv_nsec, a long, with %ld instead of %lu, and cast it to long,
as it is a long long on x32.
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/net/ipsec.c | 2 +-
tools/testing/selftests/net/tcp_ao/lib/ftrace-tcp.c | 2 +-
tools/testing/selftests/net/txtimestamp.c | 9 +++++----
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/net/ipsec.c b/tools/testing/selftests/net/ipsec.c
index 89c32c354c008..ba8c36a93f176 100644
--- a/tools/testing/selftests/net/ipsec.c
+++ b/tools/testing/selftests/net/ipsec.c
@@ -2030,7 +2030,7 @@ static int __write_desc(int test_desc_fd, struct xfrm_desc *desc)
if (ret == sizeof(*desc))
return 0;
- pr_err("Writing test's desc failed %ld", ret);
+ pr_err("Writing test's desc failed %zd", ret);
return -1;
}
diff --git a/tools/testing/selftests/net/tcp_ao/lib/ftrace-tcp.c b/tools/testing/selftests/net/tcp_ao/lib/ftrace-tcp.c
index 27403f8750547..cd93ff8965dda 100644
--- a/tools/testing/selftests/net/tcp_ao/lib/ftrace-tcp.c
+++ b/tools/testing/selftests/net/tcp_ao/lib/ftrace-tcp.c
@@ -504,7 +504,7 @@ static int setup_tcp_trace_events(struct test_ftracer *tracer)
size_t i;
int ret;
- filter = test_sprintf("net_cookie == %zu || net_cookie == %zu",
+ filter = test_sprintf("net_cookie == %" PRIu64 " || net_cookie == %" PRIu64,
ns_cookie1, ns_cookie2);
if (!filter)
return -ENOMEM;
diff --git a/tools/testing/selftests/net/txtimestamp.c b/tools/testing/selftests/net/txtimestamp.c
index f7bdf30b78d9f..be1452d73b303 100644
--- a/tools/testing/selftests/net/txtimestamp.c
+++ b/tools/testing/selftests/net/txtimestamp.c
@@ -188,12 +188,13 @@ static void __print_timestamp(const char *name, struct timespec *cur,
return;
if (cfg_print_nsec)
- fprintf(stderr, " %s: %lu s %lu ns (seq=%u, len=%u)",
- name, cur->tv_sec, cur->tv_nsec,
+ fprintf(stderr, " %s: %lld s %ld ns (seq=%u, len=%u)",
+ name, (long long)cur->tv_sec, (long)cur->tv_nsec,
key, payload_len);
else
- fprintf(stderr, " %s: %lu s %lu us (seq=%u, len=%u)",
- name, cur->tv_sec, cur->tv_nsec / NSEC_PER_USEC,
+ fprintf(stderr, " %s: %lld s %ld us (seq=%u, len=%u)",
+ name, (long long)cur->tv_sec,
+ (long)(cur->tv_nsec / NSEC_PER_USEC),
key, payload_len);
if (cur != &ts_usr) {
--
2.53.0
Re: [PATCH] selftests: net: fix format warnings on 32-bit architectures
Author: Mohsin Bashir
Date: Tue, 03 Nov 2026 17:59
Date: Tue, 03 Nov 2026 17:59
79 lines
14666 bytes
14666 bytes
On 11/3/26 7:55 AM, Sasha Levin wrote:
> On 32-bit architectures ssize_t is an int, tv_sec is a long long with a
> 64-bit time_t, and uint64_t is not a size_t, so ipsec, txtimestamp and
> the tcp_ao library warn when printing them with %ld, %lu and %zu:
>
> txtimestamp.c:191:42: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type '__time64_t' {aka 'long long int'} [-Wformat=]
>
> Print ssize_t with %zd, tv_sec as long long, and the net namespace
> cookies with PRIu64 as the rest of ftrace-tcp.c already does. While at
> it, print tv_nsec, a long, with %ld instead of %lu, and cast it to long,
> as it is a long long on x32.
>
> 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/net/ipsec.c | 2 +-
> tools/testing/selftests/net/tcp_ao/lib/ftrace-tcp.c | 2 +-
> tools/testing/selftests/net/txtimestamp.c | 9 +++++----
> 3 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/tools/testing/selftests/net/ipsec.c b/tools/testing/selftests/net/ipsec.c
> index 89c32c354c008..ba8c36a93f176 100644
> --- a/tools/testing/selftests/net/ipsec.c
> +++ b/tools/testing/selftests/net/ipsec.c
> @@ -2030,7 +2030,7 @@ static int __write_desc(int test_desc_fd, struct xfrm_desc *desc)
> if (ret == sizeof(*desc))
> return 0;
>
> - pr_err("Writing test's desc failed %ld", ret);
> + pr_err("Writing test's desc failed %zd", ret);
>
> return -1;
> }
> diff --git a/tools/testing/selftests/net/tcp_ao/lib/ftrace-tcp.c b/tools/testing/selftests/net/tcp_ao/lib/ftrace-tcp.c
> index 27403f8750547..cd93ff8965dda 100644
> --- a/tools/testing/selftests/net/tcp_ao/lib/ftrace-tcp.c
> +++ b/tools/testing/selftests/net/tcp_ao/lib/ftrace-tcp.c
> @@ -504,7 +504,7 @@ static int setup_tcp_trace_events(struct test_ftracer *tracer)
> size_t i;
> int ret;
>
> - filter = test_sprintf("net_cookie == %zu || net_cookie == %zu",
> + filter = test_sprintf("net_cookie == %" PRIu64 " || net_cookie == %" PRIu64,
> ns_cookie1, ns_cookie2);
> if (!filter)
> return -ENOMEM;
> diff --git a/tools/testing/selftests/net/txtimestamp.c b/tools/testing/selftests/net/txtimestamp.c
> index f7bdf30b78d9f..be1452d73b303 100644
> --- a/tools/testing/selftests/net/txtimestamp.c
> +++ b/tools/testing/selftests/net/txtimestamp.c
> @@ -188,12 +188,13 @@ static void __print_timestamp(const char *name, struct timespec *cur,
> return;
>
> if (cfg_print_nsec)
> - fprintf(stderr, " %s: %lu s %lu ns (seq=%u, len=%u)",
> - name, cur->tv_sec, cur->tv_nsec,
> + fprintf(stderr, " %s: %lld s %ld ns (seq=%u, len=%u)",
> + name, (long long)cur->tv_sec, (long)cur->tv_nsec,
> key, payload_len);
> else
> - fprintf(stderr, " %s: %lu s %lu us (seq=%u, len=%u)",
> - name, cur->tv_sec, cur->tv_nsec / NSEC_PER_USEC,
> + fprintf(stderr, " %s: %lld s %ld us (seq=%u, len=%u)",
> + name, (long long)cur->tv_sec,
> + (long)(cur->tv_nsec / NSEC_PER_USEC),
> key, payload_len);
>
> if (cur != &ts_usr) {
Reviewed-by: Mohsin Bashir <hmohsin@meta.com>
Re: [PATCH] selftests: net: fix format warnings on 32-bit architectures
Author: Hangbin Liu
Date: Wed, 04 Nov 2026 01:36
Date: Wed, 04 Nov 2026 01:36
80 lines
11982 bytes
11982 bytes
On Tue, Nov 03, 2026 at 10:55:03AM -0500, Sasha Levin wrote:
> On 32-bit architectures ssize_t is an int, tv_sec is a long long with a
> 64-bit time_t, and uint64_t is not a size_t, so ipsec, txtimestamp and
> the tcp_ao library warn when printing them with %ld, %lu and %zu:
>
> txtimestamp.c:191:42: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type '__time64_t' {aka 'long long int'} [-Wformat=]
>
> Print ssize_t with %zd, tv_sec as long long, and the net namespace
> cookies with PRIu64 as the rest of ftrace-tcp.c already does. While at
> it, print tv_nsec, a long, with %ld instead of %lu, and cast it to long,
> as it is a long long on x32.
>
> 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/net/ipsec.c | 2 +-
> tools/testing/selftests/net/tcp_ao/lib/ftrace-tcp.c | 2 +-
> tools/testing/selftests/net/txtimestamp.c | 9 +++++----
> 3 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/tools/testing/selftests/net/ipsec.c b/tools/testing/selftests/net/ipsec.c
> index 89c32c354c008..ba8c36a93f176 100644
> --- a/tools/testing/selftests/net/ipsec.c
> +++ b/tools/testing/selftests/net/ipsec.c
> @@ -2030,7 +2030,7 @@ static int __write_desc(int test_desc_fd, struct xfrm_desc *desc)
> if (ret == sizeof(*desc))
> return 0;
>
> - pr_err("Writing test's desc failed %ld", ret);
> + pr_err("Writing test's desc failed %zd", ret);
>
> return -1;
> }
> diff --git a/tools/testing/selftests/net/tcp_ao/lib/ftrace-tcp.c b/tools/testing/selftests/net/tcp_ao/lib/ftrace-tcp.c
> index 27403f8750547..cd93ff8965dda 100644
> --- a/tools/testing/selftests/net/tcp_ao/lib/ftrace-tcp.c
> +++ b/tools/testing/selftests/net/tcp_ao/lib/ftrace-tcp.c
> @@ -504,7 +504,7 @@ static int setup_tcp_trace_events(struct test_ftracer *tracer)
> size_t i;
> int ret;
>
> - filter = test_sprintf("net_cookie == %zu || net_cookie == %zu",
> + filter = test_sprintf("net_cookie == %" PRIu64 " || net_cookie == %" PRIu64,
> ns_cookie1, ns_cookie2);
> if (!filter)
> return -ENOMEM;
> diff --git a/tools/testing/selftests/net/txtimestamp.c b/tools/testing/selftests/net/txtimestamp.c
> index f7bdf30b78d9f..be1452d73b303 100644
> --- a/tools/testing/selftests/net/txtimestamp.c
> +++ b/tools/testing/selftests/net/txtimestamp.c
> @@ -188,12 +188,13 @@ static void __print_timestamp(const char *name, struct timespec *cur,
> return;
>
> if (cfg_print_nsec)
> - fprintf(stderr, " %s: %lu s %lu ns (seq=%u, len=%u)",
> - name, cur->tv_sec, cur->tv_nsec,
> + fprintf(stderr, " %s: %lld s %ld ns (seq=%u, len=%u)",
> + name, (long long)cur->tv_sec, (long)cur->tv_nsec,
> key, payload_len);
> else
> - fprintf(stderr, " %s: %lu s %lu us (seq=%u, len=%u)",
> - name, cur->tv_sec, cur->tv_nsec / NSEC_PER_USEC,
> + fprintf(stderr, " %s: %lld s %ld us (seq=%u, len=%u)",
> + name, (long long)cur->tv_sec,
> + (long)(cur->tv_nsec / NSEC_PER_USEC),
> key, payload_len);
>
> if (cur != &ts_usr) {
> --
> 2.53.0
>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Re: [PATCH] selftests: net: fix format warnings on 32-bit architectures
Author: patchwork-bot+netdevbpf
Date: Fri, 06 Nov 2026 22:50
Date: Fri, 06 Nov 2026 22:50
28 lines
9062 bytes
9062 bytes
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 3 Nov 2026 10:55:03 -0500 you wrote:
> On 32-bit architectures ssize_t is an int, tv_sec is a long long with a
> 64-bit time_t, and uint64_t is not a size_t, so ipsec, txtimestamp and
> the tcp_ao library warn when printing them with %ld, %lu and %zu:
>
> txtimestamp.c:191:42: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type '__time64_t' {aka 'long long int'} [-Wformat=]
>
> Print ssize_t with %zd, tv_sec as long long, and the net namespace
> cookies with PRIu64 as the rest of ftrace-tcp.c already does. While at
> it, print tv_nsec, a long, with %ld instead of %lu, and cast it to long,
> as it is a long long on x32.
>
> [...]
Here is the summary with links:
- selftests: net: fix format warnings on 32-bit architectures
https://git.kernel.org/netdev/net-next/c/205f10778a94
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads