🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10735

Re: [PATCH] selftests: net: tcp_ao: don't shift a size_t by 32

#10735
From: Hangbin Liu
Date: Wed, 04 Nov 2026 01:42
40 lines
9886 bytes
On Tue, Nov 03, 2026 at 11:39:21AM -0500, Sasha Levin wrote:
> gen_tcp_addr() shifts the size_t n right by 32 and masks it with BIT(32)
> - 1. On 32-bit architectures both shifts are as wide as the type, which
> is undefined:
> 
>   aolib.h:230:40: warning: right shift count >= width of type [-Wshift-count-overflow]
> 
> Convert n to uint64_t first and mask with 0xffffffff.
> 
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
> Found with 32-bit builds of the selftests (gcc 16 and clang 21 with
> -m32, with and without -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64);
> KernelCI's 32-bit arm builds show the same warnings. The changed files
> build without them now, and the x86_64 builds don't change.
> 
>  tools/testing/selftests/net/tcp_ao/lib/aolib.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/tcp_ao/lib/aolib.h b/tools/testing/selftests/net/tcp_ao/lib/aolib.h
> index 53be1744237ee..71ff975533089 100644
> --- a/tools/testing/selftests/net/tcp_ao/lib/aolib.h
> +++ b/tools/testing/selftests/net/tcp_ao/lib/aolib.h
> @@ -226,8 +226,8 @@ static inline union tcp_addr gen_tcp_addr(union tcp_addr net, size_t n)
>  	union tcp_addr ret = net;
>  
>  #ifdef IPV6_TEST
> -	ret.a6.s6_addr32[3] = htonl(n & (BIT(32) - 1));
> -	ret.a6.s6_addr32[2] = htonl((n >> 32) & (BIT(32) - 1));
> +	ret.a6.s6_addr32[3] = htonl((uint64_t)n & 0xffffffff);
> +	ret.a6.s6_addr32[2] = htonl((uint64_t)n >> 32);
>  #else
>  	ret.a4.s_addr = htonl(ntohl(net.a4.s_addr) + n);
>  #endif
> -- 
> 2.53.0
> 

Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Technical Details
Message-ID: <auqNhOR3Z6Lx0ggR@fedora>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356116-linux-kernel-netdev=dewy.ru
References: <20261103163921.641347-1-sashal@kernel.org>

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-356116-linux-kernel-netdev=dewy.ru
From: hangbin.liu@linux.dev (Hangbin Liu)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH] selftests: net: tcp_ao: don't shift a size_t by 32
Date: Wed, 4 Nov 2026 09:42:28 +0800
Organization: Usenet Network
Message-ID: <auqNhOR3Z6Lx0ggR@fedora>
References: <20261103163921.641347-1-sashal@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="3303268"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:kI4XCFU330LKppuPih+esZf3PiY= sha256:hRer373essoSiy/GT9wkDZgeUXIYSzIMA/+BR3Lii5Q=
	sha1:PcfJPBLeKlyFqeaLFtK5XVNYSlQ= sha256:9zFWAwiTwL3cFKf2nadGfBT1wlCkKKIUtbriGHBypM8=
Content-Disposition: inline
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 829D5112AA0; Wed,  4 Nov 2026 04:48:24 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	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 (1024-bit key)
	header.d=linux.dev
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 jyvgTi-KodcV;
	Wed,  4 Nov 2026 04:48:16 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-356116-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 8E3E21129E6; Wed,  4 Nov 2026 04:48:03 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id E303B2D3F5; Wed,  4 Nov 2026 01:42:51 +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=1793756569;
	b=RQhen1934rTX6tkrmd5ndm9qE4a3Qo1MkgBHW8LqMon+dj6qhU0cu+6StGdb0X/TFXIY
	 AKsJfLbFYwZ/VDYq49UZIOhT+6sTgsJMyElUohyNuXkZKlGlwTgJxEusVWG2AUVRtw+FK
	 p75Pa3zeCsRz/5rHvbMmT9KSHfuy8+ejJ3suEMNXxxuOcQErEP9Q7B8BjsJtnnZtu/5o9
	 oZth1V21m3QCYePC60nxL4et62pJ3dnzKT5LUig5B9q4qLnG95bNGnZA3FyA6Hufnb/8S
	 6R1W2lYY7254ATnW7/16x5rwDkOnZxOzlzJCNTaZhDUjDRPWuhpA9nDhbnveiEGXDzw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793756569;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:
	 Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=nWp1QkiE8UQYLRHEuq1OCW+NhhQpDG2WoI/kzQ0ag9s=;
	b=YdZyBEuy4l8PyuQZZjjvkm6tp1N16IIrdypwrzOvc09n/ovjeh3eygW9U1uebaE4uAqN
	 UCVX1dzB5Qa8RxD1QAKA3V7BeZIPqQ9AUQ3dEjQkc8RvX3Kt+6q9rOKRRBx6Wa61fspFN
	 lOTR+i+6MKaIBbDtluDXeWSrCCVMD7aJ3QlX655ZHNxgYltc+l+mu4pybIxFzvpvJ1ESo
	 3wFMajEejJInCEqb70KO/MW7o2QTDuLH3eWSDLVDcRIFDJS0F8/9/A4zNSXsugJM+pAZT
	 1SyIZzK0BKatwzirGfudjrdLUgbDpdT3cpMm6pwaZScI1bIJEo7MvTM59XT6HUMDPiw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="GW/Ebttp";
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	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 D59E3606A335;
	Wed,  4 Nov 2026 01:42:49 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=GW/Ebttp
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.50
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793756569;
	b=S4nsG5fjGUOhAl4s6wsSd0knEgvEw++Uge5PLaFy9Ah7onsThZ5qLqtrTpbboTot2s5C
	 CO1oogrv/uEdAdo2NiTCcF3eErWVT9zUYRJUQLgfry57xvzieiFgqFOW2248u3qmMItUH
	 //Ig4Prr+AIHhCPJ3rlo97KJnscX9F+YZne1A3by00og+nDfL6ueQvOR503oM2ASWI6FS
	 YUN74CGr6B1nYIRBuAiSxoir0CZmOpRhYfk8gv+I3O5fcXYB54L0Eb2mm8DCUTtsU5guS
	 h0KIeraXSDGQKwzvYtsziv5UXT7GPNPP3LHU9Ltr9mMNObv6lSzvGpTF2O4sHwSQ9YQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793756569;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=nWp1QkiE8UQYLRHEuq1OCW+NhhQpDG2WoI/kzQ0ag9s=;
	b=niYvoEltklo5U7X7a4M4b6JxFFUvgRghk3QBdvK6bug/x0uFhcAZIFlRgTbO7fssNX9y
	 l1VwZg1T4TEK/O5HraCCKdbmGegGCameM6AfQrrkA3fIoA60Hzot7Vy0vh49GdJztz+bA
	 DHJA1NpOxGsV8yQMCmX5aQ2bFMx3p7kS91TGaCp4cb92HmYBJ12TkwA6yw73eDxbTIUeN
	 dhF2bd8KqUMKtT8Tr2ucIbUR9ewiW9VxIulYAkzCGdcaIQnZsRGDmq2CBfh3WB9GXWyZr
	 n7+tXYmJUlk9eRLpwDgaTqKT7S/uPdxSp/1eWeOow1KbblVYox/8taN0MGoiJ+EgD5Q==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="GW/Ebttp";
	arc=none smtp.remote-ip=95.215.58.50
X-Received: from mta1.migadu.com (out-50.mta1.migadu.com [95.215.58.50])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63804606A326
	for <netdev@vger.kernel.org>; Wed,  4 Nov 2026 01:42:48 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 63804606A326
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=YX/s6/HwMM+QXcGKjPYZwlkwikDGqHDXoSO3cMoqP6I=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1793756566; v=1; x=1794361366;
 b=GW/EbttpRAwg7oIXRQuQlJyfSFZ5C1PMpzxUmhAMreigDkimGv21maCnrZ9lz9ff58h81Y6s
 4WgEJvpPgi88r0PfzlWrSe9aBKZDxSr/IiJ6JDL/1zPzxjXia/CelsxpCopjxeKvyZD4RqA4qe8
 Ft4mcaMLefHAhrCPkFHPyHsA=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by mta11.migadu.com with ESMTPS id b3c20ee6540bb41b;
	Wed, 04 Nov 2026 01:42:46 +0000
X-Mizu-Trace-ID: b3c20ee6540bb41b
X-Migadu-Flow: FLOW_OUT
X-Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Dmitry Safonov <0x7f454c46@gmail.com>,
	Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>,
	netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
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
X-In-Reply-To: <20261103163921.641347-1-sashal@kernel.org>