* linux-6.15-rc2/tools/testing/selftests/kvm/lib/arm64/processor.c:107: Possible int/long mixup ?
@ 2025-04-14 18:02 David Binderman
2025-04-14 18:28 ` Oliver Upton
0 siblings, 1 reply; 2+ messages in thread
From: David Binderman @ 2025-04-14 18:02 UTC (permalink / raw)
To: maz@kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com,
suzuki.poulose@arm.com, yuzenghui@huawei.com, pbonzini@redhat.com,
shuah@kernel.org, linux-arm-kernel@lists.infradead.org,
kvmarm@lists.linux.dev, kvm@vger.kernel.org,
linux-kselftest@vger.kernel.org
Hello there,
Static analyser cppcheck says:
linux-6.15-rc2/tools/testing/selftests/kvm/lib/arm64/processor.c:107:2: style: int result is returned as long value. If the return value is long to avoid loss of information, then you have loss of information. [truncLongCastReturn]
Source code is
return 1 << (vm->va_bits - shift);
Maybe better code:
return 1UL << (vm->va_bits - shift);
Regards
David Binderman
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: linux-6.15-rc2/tools/testing/selftests/kvm/lib/arm64/processor.c:107: Possible int/long mixup ?
2025-04-14 18:02 linux-6.15-rc2/tools/testing/selftests/kvm/lib/arm64/processor.c:107: Possible int/long mixup ? David Binderman
@ 2025-04-14 18:28 ` Oliver Upton
0 siblings, 0 replies; 2+ messages in thread
From: Oliver Upton @ 2025-04-14 18:28 UTC (permalink / raw)
To: David Binderman
Cc: maz@kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com,
yuzenghui@huawei.com, pbonzini@redhat.com, shuah@kernel.org,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
kvm@vger.kernel.org, linux-kselftest@vger.kernel.org
On Mon, Apr 14, 2025 at 06:02:45PM +0000, David Binderman wrote:
> Hello there,
>
> Static analyser cppcheck says:
>
> linux-6.15-rc2/tools/testing/selftests/kvm/lib/arm64/processor.c:107:2: style: int result is returned as long value. If the return value is long to avoid loss of information, then you have loss of information. [truncLongCastReturn]
>
> Source code is
>
> return 1 << (vm->va_bits - shift);
>
> Maybe better code:
>
> return 1UL << (vm->va_bits - shift);
>
This expression is at most 8192 so there's no risk of truncation,
although the return type could potentially be improved.
Thanks,
Oliver
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-14 18:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-14 18:02 linux-6.15-rc2/tools/testing/selftests/kvm/lib/arm64/processor.c:107: Possible int/long mixup ? David Binderman
2025-04-14 18:28 ` Oliver Upton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).