[U-Boot] [PATCH] fix print_size printing fractional gigabyte numbers on 32-bit platforms

Timur Tabi timur at freescale.com
Wed Mar 31 00:08:47 CEST 2010


Scott Wood wrote:
> In changing "d" from phys_size_t to unsigned long, I think you're 
> introducing overflow in "n * d" (consider 5.5G rather than 1.5G).
> 
> Wouldn't a more straightforward fix, that doesn't affect the function 
> signature, be to just change "10 *" to "10ULL *"?

I don't see how that suggestion would make the code any different.  Here's the expression:

	(10 * (size - (n * d)) + (d / 2) ) / d;

I made 'size' into a u64, and I assume that the compiler will evaluate every other subexpression as a u64.  That may be wrong.

However, changing 10 to 10ULL makes the same assumption.

I'll test 5.5GB and see what it does.

-- 
Timur Tabi
Linux kernel developer at Freescale


More information about the U-Boot mailing list