🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10516

[PATCH] selftests: net: fix format warnings on 32-bit architectures

#10516
From: Sasha Levin
Date: Tue, 03 Nov 2026 15:55
76 lines
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
Technical Details
Message-ID: <20261103155503.534876-1-sashal@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355775-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355775-linux-kernel-netdev=dewy.ru
From: sashal@kernel.org (Sasha Levin)
Newsgroups: linux.kernel.netdev
Subject: [PATCH] selftests: net: fix format warnings on 32-bit architectures
Date: Tue,  3 Nov 2026 10:55:03 -0500
Organization: Usenet Network
Message-ID: <20261103155503.534876-1-sashal@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3207977"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:kDQV0l/MqEa2J8s3lN0R0Ed5yZw= sha256:b2YPl0RqC97Mz9gWELpoUbviWz9ocgU92rDFjf0yy0U=
	sha1:LZ4m1BXQZUgCgxNy40C8RrYuu1o= sha256:aicwH/+Z7iiQ/0mlL0qHwRd438tX7UPJTVfs6WrC+Z8=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id A6757112948; Tue,  3 Nov 2026 19:18:13 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id COxvb_lJrVnT;
	Tue,  3 Nov 2026 19:18:10 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-355775-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id B549B112944; Tue,  3 Nov 2026 19:18:05 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 3B6D160C839; Tue,  3 Nov 2026 15:56:49 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793721322;
	b=Bd/J06CgDD7YDq/7HxblRLiavH7uXhIBstcsvlox/qDO/GZuJVyf2Hap8NEnhEdfVhKR
	 Az0a+O8rDqH/Iokg2FnsCZzaqL+g9jXMtha7S9/+yQQ19InH4bGcmc28TWxfvfekPAOfc
	 oK19TbUnEbpKiqmrwcYbTTqSqFUjWMqvtdIWT69a/OJKhazXvYDmsvMUz92FNokeTC3g8
	 xBnI5bAg69SdPIsk5aQBBKsTocTSFKdQXGc6jdx4Ih0QShk7IZ06rSzPslBIsDK94Dlnl
	 j+ZrxAuuldB0xlTyClH8WZwi9I+sdK++nbiFf71nQkszCFZYdwYVVR75K2qwwzlQCbQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793721322;
	h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=XREKEeftscoz1Hi8GedJ6sHaQ24A+16k7dbdppJWu+c=;
	b=Ma4C+mku9AGMMBSPePTKdIAPP6PYOVT3vWG55ebJi9Ngf12SLsPRqZerzFPSzlBysiu7
	 o5Qqm2r5ekiC70hRgjemmqvTxJwWjyhhxS65i0wGv3oL/DGxbBjubaQVl6P6EtdUQEkps
	 wS9H90zFoMWVW1El+wJ/s2rKduQKbKAzjY0ShIzuVnZvFd947pQGBoYNJdUZdNRgJoBsa
	 hYkp6jwNPInggRTfvYyM//+ZJYguRvNWj4DSOYNjDE0VD2JkiGGWyJtott05eY++VXxJq
	 IMWUwgmQiP/55U40zI/ryqGkJ3ZZ76EzF8kuhGzWtb+GjctM5S9ZXlMJkApTv5quptw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=c94PUqed;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B726606A337;
	Tue,  3 Nov 2026 15:55:22 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=c94PUqed
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793721306;
	b=U1IwRdyWMyGVN+rhFGjZSAScLtTdywPN4/ElcmmQRPouPx4es0ZF4Zt2uYpwkwZ8TUJd
	 DxpQ4IcGUOo1fpuoTniiawTVL451xmXRPbaQppLxWIfXQq+o5UiJxDRnUH6BvHm9vUYGE
	 2sZlluxZnfLDS7YNQo1kFiGkW4olIjJzmZ4HA56FC4eJKq0d6gFJR/OFNrieDxMhL6Wm/
	 4vtN/dmNa0mX6vvsTRy/aFZP9RUTCvQee7e27KgPvi9zS1rmeVm432JRHyS6dAhuSltif
	 /qztDEZdLb4kKsLGi4OZM1q3ls2kNRQ22Cwgjr2+1VZdNOagYbv+00qGsj3oyqI7jTA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793721306;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 MIME-Version:Content-Transfer-Encoding;
	bh=XREKEeftscoz1Hi8GedJ6sHaQ24A+16k7dbdppJWu+c=;
	b=ch+LeL3988ZNRxRCclZuXVcvUUFkvVe6F9x6F5J8UBdGPXxyjYs4Avi4Yypskep2VFD/
	 FSPpy/QQLXdayX6eSp+eS40d18b/kiYA6VdGrMclhgOhz69KQZPqFVEH74EkROB5zB9XZ
	 yAABHlg370iUvLb0XFFigogI8yVpEJcvewg+bDc5pWXPSC4qjLJtACiHORT7vys2OeQ8b
	 ta44dkRlNwh2jGYEvmL6U7nS2SfYGUm0pyb3WSw9zMMXbqnX209fCv4RjHq1T7px8uCm8
	 PKAnDHcBjR/ksschu5xz7rzi3eo1Yg4uJUU7xMu0RUFv4kNOK9+ZYpf7o5iz/H2wtmg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=c94PUqed;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C031606A332;
	Tue,  3 Nov 2026 15:55:05 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 775281F00A1D;
	Tue,  3 Nov 2026 15:55:04 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793721305;
	bh=XREKEeftscoz1Hi8GedJ6sHaQ24A+16k7dbdppJWu+c=;
	h=From:To:Cc:Subject:Date;
	b=c94PUqeddn/1T6sh1Ph5uX9dXjXrVhLiuzaw8PGT8I5Bndy7Fuv5EokDK6a00EUUw
	 QPqp8XBih9PeVEHP+DQhZfEQfByb885n4IvpeuejxQftb+nRjCy7QgLEL5QUdaaHDD
	 dTZDcnMVTVbC1wojEFcroWovwRbZsOCw6jVMXtgpGS6vuwyy4zRp1QCDkDXN7lve5P
	 B7NCmtr074deIEYEQQ3py3459q9ooTwF2AWjSMQmSyaPSHAmqL4I8gZAtdjb1u8UIr
	 UhGNDPu6N58ccxPz73CAj2j7u9CM0JLDYJIfQ/digYaiqNf2fC91xeScgSOcHvatrS
	 30AHc4Fr9Wdbg==
X-Cc: Simon Horman <horms@kernel.org>,
	Shuah Khan <shuah@kernel.org>,
	Jason Xing <kerneljasonxing@gmail.com>,
	netdev@vger.kernel.org,
	linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.53.0
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list