Re: linux-6.15-rc2/drivers/xen/balloon.c:346: Possible int/long mixup

From: Jürgen Groß
Date: Tue Apr 15 2025 - 02:57:21 EST


On 14.04.25 19:57, David Binderman wrote:
Hello there,

Static analyser cppcheck says:

linux-6.15-rc2/drivers/xen/balloon.c:346:24: style: int result is assigned to long variable. If the variable is long to avoid loss of information, then you have loss of information. [truncLongCastAssignment]

Source code is

unsigned long i, size = (1 << order);

Maybe better code:

unsigned long i, size = (1UL << order);


While I agree this would be better, there is no real failure possible
here. For this to cause problems you'd need to hotplug 16TB of memory
in one single block.

Nevertheless thanks for the notice.


Juergen

Attachment: OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature