* linux-6.15-rc2/drivers/xen/balloon.c:346: Possible int/long mixup
@ 2025-04-14 17:57 David Binderman
2025-04-15 6:55 ` Jürgen Groß
0 siblings, 1 reply; 2+ messages in thread
From: David Binderman @ 2025-04-14 17:57 UTC (permalink / raw)
To: jgross, sstabellini, oleksandr_tyshchenko, xen-devel,
Linux Kernel Mailing List
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);
Regards
David Binderman
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: linux-6.15-rc2/drivers/xen/balloon.c:346: Possible int/long mixup
2025-04-14 17:57 linux-6.15-rc2/drivers/xen/balloon.c:346: Possible int/long mixup David Binderman
@ 2025-04-15 6:55 ` Jürgen Groß
0 siblings, 0 replies; 2+ messages in thread
From: Jürgen Groß @ 2025-04-15 6:55 UTC (permalink / raw)
To: David Binderman, sstabellini, oleksandr_tyshchenko, xen-devel,
Linux Kernel Mailing List
[-- Attachment #1.1.1: Type: text/plain, Size: 684 bytes --]
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 #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-15 6:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-14 17:57 linux-6.15-rc2/drivers/xen/balloon.c:346: Possible int/long mixup David Binderman
2025-04-15 6:55 ` Jürgen Groß
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®