linux-6.15-rc2/tools/testing/selftests/kvm/lib/arm64/processor.c:107: Possible int/long mixup ?

Oliver Upton oliver.upton at linux.dev
Mon Apr 14 11:28:23 PDT 2025


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



More information about the linux-arm-kernel mailing list