Skip to contentSkip to conversation

disk/part.c: use unsigned format when printing capacity

PATCH New Pavel Machek 1 participant 1 message Dec 14, 2014 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 disk/part.c: use unsigned format when printing capacity

I'm afraid I'm not the right contact to merge the patch. It should probably go to Tom Rini and u-boot list. (I put them in Cc).

Pavel

Quoted 33 lines · Daniel Golle

Large disks otherwise produce highly unplausible output such as

        Capacity: 1907729.0 MB = 1863.0 GB (-387938128 x 512)

As supposedly all size-related decimals are unsigned, use unsigned format in printf statement, resulting in a correct capacity being displayed:

        Capacity: 1907729.0 MB = 1863.0 GB (3907029168 x 512)
---
 disk/part.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
disk/part.c +2 -2
index 43485c9..7c67ea6 100644
@@ -229,13 +229,13 @@ void dev_print (block_dev_desc_t *dev_desc)
 			printf ("            Supports 48-bit addressing\n");
 #endif
 #if defined(CONFIG_SYS_64BIT_LBA)
-		printf ("            Capacity: %ld.%ld MB = %ld.%ld GB (%Ld x %ld)\n",
+		printf ("            Capacity: %lu.%lu MB = %lu.%lu GB (%Lu x %lu)\n",
 			mb_quot, mb_rem,
 			gb_quot, gb_rem,
 			lba,
 			dev_desc->blksz);
 #else
-		printf ("            Capacity: %ld.%ld MB = %ld.%ld GB (%ld x %ld)\n",
+		printf ("            Capacity: %lu.%lu MB = %lu.%lu GB (%lu x %lu)\n",
 			mb_quot, mb_rem,
 			gb_quot, gb_rem,
 			(ulong)lba,
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html