public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] [v3] fix print_size printing fractional gigabyte numbers on 32-bit platforms
@ 2010-03-30 23:02 Timur Tabi
  2010-03-30 23:02 ` [U-Boot] [PATCH] allow print_size to print large numbers on 32-bit systems Timur Tabi
  2010-04-09 20:10 ` [U-Boot] [PATCH] [v3] fix print_size printing fractional gigabyte numbers on 32-bit platforms Wolfgang Denk
  0 siblings, 2 replies; 20+ messages in thread
From: Timur Tabi @ 2010-03-30 23:02 UTC (permalink / raw)
  To: u-boot

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_generic/display_options.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib_generic/display_options.c b/lib_generic/display_options.c
index 2dc2567..08a7914 100644
--- a/lib_generic/display_options.c
+++ b/lib_generic/display_options.c
@@ -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 */
-- 
1.6.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2010-04-12 19:26 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-30 23:02 [U-Boot] [PATCH] [v3] fix print_size printing fractional gigabyte numbers on 32-bit platforms Timur Tabi
2010-03-30 23:02 ` [U-Boot] [PATCH] allow print_size to print large numbers on 32-bit systems Timur Tabi
2010-04-09 20:22   ` Wolfgang Denk
2010-04-09 20:27     ` Timur Tabi
2010-04-09 20:40       ` Wolfgang Denk
2010-04-12 16:12         ` Timur Tabi
2010-04-12 16:16           ` Nick Thompson
2010-04-12 16:21             ` Timur Tabi
2010-04-12 16:27               ` Nick Thompson
2010-04-12 18:02             ` Wolfgang Denk
2010-04-12 17:59           ` Wolfgang Denk
2010-04-12 18:03             ` Timur Tabi
2010-04-12 18:20               ` Wolfgang Denk
2010-04-12 18:22               ` Scott Wood
2010-04-12 18:30                 ` Timur Tabi
2010-04-12 18:50                   ` Wolfgang Denk
2010-04-12 19:10                     ` Timur Tabi
2010-04-12 19:26                       ` Scott Wood
2010-04-09 20:10 ` [U-Boot] [PATCH] [v3] fix print_size printing fractional gigabyte numbers on 32-bit platforms Wolfgang Denk
2010-04-12 16:04   ` Timur Tabi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox