Skip to contentSkip to conversation

commands: bfetch: use 64-bit integer types for sizes

PATCH Applied Ahmad Fatoum 2 participants 2 messages Mar 29 – Apr 13

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 commands: bfetch: use 64-bit integer types for sizes

size_human_readable() accepts a 64-bit argument (unsigned long long), but we pass smaller types into it, leading to truncation when computing the total sizes for display.

Switch to 64-bit variables to fix this.

---
 commands/bfetch.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
commands/bfetch.c +3 -3
index d9c615f65aca..9dfb07aa2ab7 100644
@@ -244,7 +244,7 @@ static struct bobject *print_cpu_mem_info(unsigned *line)
 {
 	struct bobject *bret = NULL;
 	struct memory_bank *mem;
-	unsigned long memsize = 0;
+	u64 memsize = 0;
 	int nbanks = 0;
 	int ret;
 
@@ -565,9 +565,9 @@ static void print_storage(unsigned *line)
 	unsigned nmtds = 0, nnvmem =0;
 	struct block_device *blk;
 	unsigned nblkdevs[BLK_TYPE_COUNT] = {};
-	unsigned blkdev_sizes[BLK_TYPE_COUNT] = {};
+	u64 blkdev_sizes[BLK_TYPE_COUNT] = {};
 	struct mtd_info *mtd;
-	size_t mtd_size = 0, nvmem_size = 0;
+	u64 mtd_size = 0, nvmem_size = 0;
 	struct string_list sl;
 	struct device *dev;
 
Signature · 1 line
2.47.3
Applied
#1 lore raw
Quoted 8 lines · Ahmad Fatoum

size_human_readable() accepts a 64-bit argument (unsigned long long), but we pass smaller types into it, leading to truncation when computing the total sizes for display.

Switch to 64-bit variables to fix this.

[...]

Applied, thanks!

[1/1] commands: bfetch: use 64-bit integer types for sizes
https://git.pengutronix.de/cgit/barebox/commit/?id=18a66f3dd416 (link may not be stable)

Best regards,

Signature · 1 line
Sascha Hauer <[email protected]>