]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
fix print_size printing fractional gigabyte numbers on 32-bit platforms
authorTimur Tabi <timur@freescale.com>
Tue, 13 Apr 2010 18:16:02 +0000 (13:16 -0500)
committerWolfgang Denk <wd@denx.de>
Wed, 5 May 2010 20:17:07 +0000 (22:17 +0200)
In print_size(), the math that calculates the fractional remainder of a number
used the same integer size as a physical address.  However, the "10 *" factor
of the algorithm means that a large number (e.g. 1.5GB) can overflow the
integer if we're running on a 32-bit system.  Therefore, we need to
disassociate this function from the size of a physical address.

Signed-off-by: Timur Tabi <timur@freescale.com>
lib/display_options.c

index 2dc2567410ba69636d9f51fcb0dc1d55ce019cf4..08a7914a1d0bef542fd2314e3f8850a2a3e93c47 100644 (file)
@@ -45,8 +45,8 @@ int display_options (void)
  */
 void print_size (phys_size_t size, const char *s)
 {
-       ulong m = 0, n;
-       phys_size_t d = 1 << 30;                /* 1 GB */
+       unsigned long m = 0, n;
+       unsigned long long d = 1 << 30;         /* 1 GB */
        char  c = 'G';
 
        if (size < d) {                 /* try MB */