selftests: mptcp: pm_nl_ctl: print sizeof() with %zu

Started by Sasha Levin on Nov 3, 2026 · 4 messages from 4 authors · Last reply Nov 6, 2026

Subsystems (4)

Show 1 more

Maintainers (9)

Show 5 more
COOLING14d IN NET-NEXT

Status: Queued in net-next as 1146fbb8024b on 2026-11-06.

open the first message on its own page

Message details and related content
On 32-bit architectures size_t is an unsigned int, and printing
sizeof(struct nlmsgerr) with %ld warns:

  pm_nl_ctl.c:73:71: warning: format '%ld' expects argument of type 'long int', but argument 5 has type 'unsigned int' [-Wformat=]

Use %zu.

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/mptcp/pm_nl_ctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
index 78180da1efcc5..36a6d39b31bbf 100644
--- a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
+++ b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
@@ -70,7 +70,7 @@ static int nl_error(struct nlmsghdr *nh)
 	uint32_t off;
 
 	if (len < sizeof(struct nlmsgerr)) {
-		error(1, 0, "netlink error message truncated %d min %ld", len,
+		error(1, 0, "netlink error message truncated %d min %zu", len,
 		      sizeof(struct nlmsgerr));
 		return -1;
 	}
-- 
2.53.0
Message details and related content
Hi Sasha,

On 03/11/2026 16:55, Sasha Levin wrote:
On 32-bit architectures size_t is an unsigned int, and printing
sizeof(struct nlmsgerr) with %ld warns:

  pm_nl_ctl.c:73:71: warning: format '%ld' expects argument of type 'long int', but argument 5 has type 'unsigned int' [-Wformat=]

Use %zu.
Thank you for the fix, it looks good to me:

Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>

@Net maintainers: please apply this patch to net-next directly.

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.
Message details and related content
On Tue, Nov 03, 2026 at 10:55:06AM -0500, Sasha Levin wrote:
quoted hunk
On 32-bit architectures size_t is an unsigned int, and printing
sizeof(struct nlmsgerr) with %ld warns:

  pm_nl_ctl.c:73:71: warning: format '%ld' expects argument of type 'long int', but argument 5 has type 'unsigned int' [-Wformat=]

Use %zu.

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/mptcp/pm_nl_ctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
index 78180da1efcc5..36a6d39b31bbf 100644
--- a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
+++ b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
@@ -70,7 +70,7 @@ static int nl_error(struct nlmsghdr *nh)
 	uint32_t off;
 
 	if (len < sizeof(struct nlmsgerr)) {
-		error(1, 0, "netlink error message truncated %d min %ld", len,
+		error(1, 0, "netlink error message truncated %d min %zu", len,
 		      sizeof(struct nlmsgerr));
 		return -1;
 	}
-- 
2.53.0
Reviewed-by: Hangbin Liu <redacted>
Message details and related content
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski [off-list ref]:

On Tue,  3 Nov 2026 10:55:06 -0500 you wrote:
On 32-bit architectures size_t is an unsigned int, and printing
sizeof(struct nlmsgerr) with %ld warns:

  pm_nl_ctl.c:73:71: warning: format '%ld' expects argument of type 'long int', but argument 5 has type 'unsigned int' [-Wformat=]

Use %zu.

[...]
Here is the summary with links:
  - selftests: mptcp: pm_nl_ctl: print sizeof() with %zu
    https://git.kernel.org/netdev/net-next/c/1146fbb8024b

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html

Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help