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

From: Sasha Levin

Date: Thu Nov 05 2026 - 07:54:19 EST


On Thu, Nov 05, 2026 at 11:08:56AM +0000, David Laight wrote:
>On Tue, 3 Nov 2026 11:39:21 -0500
>Sasha Levin <sashal@xxxxxxxxxx> wrote:
>
>> #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);
>
>You don't need a cast or mask there.
>
>> + ret.a6.s6_addr32[2] = htonl((uint64_t)n >> 32);
>
>That can also be n >> 16 >> 16
>
>Also see upper_32_bits() and lower_32_bits() in wordpart.h
>which might not be available for selftests?

They aren't, tools/include has no copy of wordpart.h.

It works as is, but you're right, htonl(n) and htonl(n >> 16 >> 16) are enough.
Happy to respin with those if the maintainers prefer.

--
Thanks,
Sasha