From 15a4eb04228064518daf4ba6e0985e39fe64c8e9 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Fri, 15 Nov 2024 07:28:55 -0500 Subject: [PATCH] debug: Correct most of the sector_t printf()s The 'll' printf modifier is currently broken. Fortunately all but one of the uses is printing MB instead of bytes, which means we can cast the value to a 'unsigned long' without risk of overflow/wraps. ...There's one remaining use ('%llx') which still needs to be sorted out. Change-Id: I89f406f6c085be153531d1ec1f2a314ae172b129 --- apps/debug_menu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/debug_menu.c b/apps/debug_menu.c index dfc81232c7..39d9a2a4e2 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -565,12 +565,12 @@ static const char* dbg_partitions_getname(int selected_item, void *data, // XXX and if mounted, show free info... if (selected_item%2) { - snprintf(buffer, buffer_len, " T:%x %llu MB", p.type, - (uint64_t)(p.size / ( 2048 / ( SECTOR_SIZE / 512 )))); + snprintf(buffer, buffer_len, " T:%x %lu MB", p.type, + (unsigned long)(p.size / ( 2048 / ( SECTOR_SIZE / 512 )))); } else { - snprintf(buffer, buffer_len, "P%d: S:%llx", partition, (uint64_t)p.start); + snprintf(buffer, buffer_len, "P%d: S:%llx", partition, (unsigned long long)p.start); } return buffer; } @@ -1450,7 +1450,7 @@ static int disk_callback(int btn, struct gui_synclist *lists) total_sectors *= sector_size; /* Convert to bytes */ total_sectors /= (1024 * 1024); /* Convert to MB */ - simplelist_addline("Size: %llu MB", (uint64_t)total_sectors); + simplelist_addline("Size: %lu MB", (unsigned long)total_sectors); simplelist_addline("Logical sector size: %lu B", sector_size); #ifdef MAX_VIRT_SECTOR_SIZE simplelist_addline("Sector multiplier: %u", disk_get_sector_multiplier()); @@ -1466,7 +1466,7 @@ static int disk_callback(int btn, struct gui_synclist *lists) sector_t free; volume_size( IF_MV(0,) NULL, &free ); simplelist_addline( - "Free: %llu MB", (uint64_t)(free / 1024)); + "Free: %lu MB", (unsigned long)(free / 1024)); #endif simplelist_addline("SSD detected: %s", ata_disk_isssd() ? "yes" : "no"); @@ -1805,7 +1805,7 @@ static int disk_callback(int btn, struct gui_synclist *lists) simplelist_addline("Model: %s", info.product); simplelist_addline("Firmware: %s", info.revision); simplelist_addline( - "Size: %llu MB", (uint64_t)(info.num_sectors*(info.sector_size/512)/2048)); + "Size: %lu MB", (unsigned long)(info.num_sectors*(info.sector_size/512)/2048)); sector_t free; volume_size( IF_MV(0,) NULL, &free ); simplelist_addline(