From mboxrd@z Thu Jan 1 00:00:00 1970 From: Timur Tabi Date: Tue, 30 Mar 2010 17:08:47 -0500 Subject: [U-Boot] [PATCH] fix print_size printing fractional gigabyte numbers on 32-bit platforms In-Reply-To: <4BB275B7.90509@freescale.com> References: <1269985996-13130-1-git-send-email-timur@freescale.com> <4BB275B7.90509@freescale.com> Message-ID: <4BB2766F.9070808@freescale.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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