From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scott Wood Date: Tue, 30 Mar 2010 17:43:17 -0500 Subject: [U-Boot] [PATCH] [v2] fix print_size printing fractional gigabyte numbers on 32-bit platforms In-Reply-To: <1269988459-20892-1-git-send-email-timur@freescale.com> References: <1269988459-20892-1-git-send-email-timur@freescale.com> Message-ID: <4BB27E85.60704@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 Timur Tabi wrote: > 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 > --- > include/common.h | 2 +- > lib_generic/display_options.c | 6 +++--- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/include/common.h b/include/common.h > index a133e34..4e77727 100644 > --- a/include/common.h > +++ b/include/common.h > @@ -218,7 +218,7 @@ void hang (void) __attribute__ ((noreturn)); > /* */ > phys_size_t initdram (int); > int display_options (void); > -void print_size (phys_size_t, const char *); > +void print_size(unsigned long long, const char *); As stated before, the overflow is an implementation detail. There's no reason to change the interface unless there's a desire to support printing sizes larger than phys_size_t, which is a distinct issue from the bugfix. -Scott