:: commit 00a542f0c6dd86f794819761737f4888d2cced14

Mintsuki <mintsuki@protonmail.com> — 2026-02-08 15:49

parents: 8bf787fa10

misc: Fix wrong format specifiers for 64-bit arguments in print calls

diff --git a/common/drivers/gop.c b/common/drivers/gop.c
index 266a1bbb..2f2ac0f7 100644
--- a/common/drivers/gop.c
+++ b/common/drivers/gop.c
@@ -138,7 +138,7 @@ static bool try_mode(struct fb_info *ret, EFI_GRAPHICS_OUTPUT_PROTOCOL *gop,
         }
     }
 
-    printv("gop: Found matching mode %x, attempting to set...\n", mode);
+    printv("gop: Found matching mode %X, attempting to set...\n", (uint64_t)mode);
 
     if (mode == gop->Mode->Mode) {
         printv("gop: Mode was already set, perfect!\n");
@@ -146,7 +146,7 @@ static bool try_mode(struct fb_info *ret, EFI_GRAPHICS_OUTPUT_PROTOCOL *gop,
         status = gop->SetMode(gop, mode);
 
         if (status) {
-            printv("gop: Failed to set video mode %x, moving on...\n", mode);
+            printv("gop: Failed to set video mode %X, moving on...\n", (uint64_t)mode);
             return false;
         }
     }
diff --git a/common/lib/acpi.c b/common/lib/acpi.c
index 40274ca5..20cd08c4 100644
--- a/common/lib/acpi.c
+++ b/common/lib/acpi.c
@@ -160,7 +160,7 @@ void acpi_get_smbios(void **smbios32, void **smbios64) {
         if (acpi_checksum((void *)ptr, ptr->length) != 0)
             continue;
 
-        printv("acpi: Found SMBIOS 32-bit entry point at %X\n", ptr);
+        printv("acpi: Found SMBIOS 32-bit entry point at %p\n", ptr);
 
         *smbios32 = (void *)ptr;
 
@@ -179,7 +179,7 @@ void acpi_get_smbios(void **smbios32, void **smbios64) {
         if (acpi_checksum((void *)ptr, ptr->length) != 0)
             continue;
 
-        printv("acpi: Found SMBIOS 64-bit entry point at %X\n", ptr);
+        printv("acpi: Found SMBIOS 64-bit entry point at %p\n", ptr);
 
         *smbios64 = (void *)ptr;
 
@@ -245,7 +245,7 @@ void *acpi_get_table(const char *signature, int index) {
         if (!memcmp(ptr->signature, signature, 4)
          && !acpi_checksum(ptr, ptr->length)
          && cnt++ == index) {
-            printv("acpi: Found \"%s\" at %x\n", signature, ptr);
+            printv("acpi: Found \"%s\" at %p\n", signature, ptr);
             return ptr;
         }
     }
diff --git a/common/lib/config.c b/common/lib/config.c
index 5493a931..ee718f81 100644
--- a/common/lib/config.c
+++ b/common/lib/config.c
@@ -441,7 +441,7 @@ skip_loop:
             for (j = 0; config_addr[i] != '}' && config_addr[i] != '\n' && config_addr[i] != 0; j++, i++) {
                 if (j >= sizeof(macro->name) - 1) {
                     bad_config = true;
-                    panic(true, "config: Macro name too long (max %u)", sizeof(macro->name) - 1);
+                    panic(true, "config: Macro name too long (max %U)", (uint64_t)(sizeof(macro->name) - 1));
                 }
                 macro->name[j] = config_addr[i];
             }
@@ -457,7 +457,7 @@ skip_loop:
             for (j = 0; config_addr[i] != '\n' && config_addr[i] != 0; j++, i++) {
                 if (j >= sizeof(macro->value) - 1) {
                     bad_config = true;
-                    panic(true, "config: Macro value too long (max %u)", sizeof(macro->value) - 1);
+                    panic(true, "config: Macro value too long (max %U)", (uint64_t)(sizeof(macro->value) - 1));
                 }
                 macro->value[j] = config_addr[i];
             }
diff --git a/common/lib/gterm.c b/common/lib/gterm.c
index 0c8f01a4..08712a73 100644
--- a/common/lib/gterm.c
+++ b/common/lib/gterm.c
@@ -710,7 +710,7 @@ bool gterm_init(struct fb_info **_fbs, size_t *_fbs_count,
         size_t tmp_font_size = (tmp_font_width * tmp_font_height * FLANTERM_FB_FONT_GLYPHS) / 8;
 
         if (tmp_font_size > FONT_MAX) {
-            print("Font would be too large (%u bytes, %u bytes allowed). Not loading.\n", tmp_font_size, FONT_MAX);
+            print("Font would be too large (%U bytes, %u bytes allowed). Not loading.\n", (uint64_t)tmp_font_size, FONT_MAX);
             goto no_load_font;
         }
 
diff --git a/common/lib/misc.c b/common/lib/misc.c
index 4836aff7..00e8a02e 100644
--- a/common/lib/misc.c
+++ b/common/lib/misc.c
@@ -197,7 +197,7 @@ void *get_device_tree_blob(const char *config, size_t extra_size) {
     }
 
     if (dtb) {
-        printv("dtb: dtb has size %x\n", size);
+        printv("dtb: dtb has size %X\n", (uint64_t)size);
 
         void *new_tab = ext_mem_alloc(size + extra_size);
 
diff --git a/common/lib/pe.c b/common/lib/pe.c
index 5078d42f..6fbed5b3 100644
--- a/common/lib/pe.c
+++ b/common/lib/pe.c
@@ -328,12 +328,12 @@ again:
 
         // Validate section doesn't write past the image buffer
         if ((uint64_t)section->VirtualAddress + section_raw_size > image_size) {
-            panic(true, "pe: Section %zu exceeds image bounds", i);
+            panic(true, "pe: Section %U exceeds image bounds", (uint64_t)i);
         }
 
         // Validate section data doesn't exceed file bounds
         if ((uint64_t)section->PointerToRawData + section_raw_size > file_size) {
-            panic(true, "pe: Section %zu data extends beyond file bounds", i);
+            panic(true, "pe: Section %U data extends beyond file bounds", (uint64_t)i);
         }
 
         memcpy((void *)section_base, image + section->PointerToRawData, section_raw_size);
diff --git a/common/menu.c b/common/menu.c
index feba0760..2a066fe6 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -1090,8 +1090,8 @@ refresh:
         for (size_t i = timeout; i; i--) {
             set_cursor_pos_helper(0, terms[0]->rows - 1);
             FOR_TERM(TERM->scroll_enabled = false);
-            print("\e[2K%sBooting automatically in %s%u%s, press any key to stop the countdown...\e[0m",
-                  interface_help_colour, interface_help_colour_bright, i, interface_help_colour);
+            print("\e[2K%sBooting automatically in %s%U%s, press any key to stop the countdown...\e[0m",
+                  interface_help_colour, interface_help_colour_bright, (uint64_t)i, interface_help_colour);
             FOR_TERM(TERM->scroll_enabled = true);
             FOR_TERM(TERM->double_buffer_flush(TERM));
             if ((c = pit_sleep_and_quit_on_keypress(1))) {
diff --git a/common/mm/pmm.s2.c b/common/mm/pmm.s2.c
index a309dbb5..1743999d 100644
--- a/common/mm/pmm.s2.c
+++ b/common/mm/pmm.s2.c
@@ -545,7 +545,7 @@ void pmm_release_uefi_mem(void) {
         status = gBS->FreePages(untouched_memmap[i].base, untouched_memmap[i].length / 4096);
 
         if (status) {
-            panic(false, "pmm: FreePages failure (%x)", status);
+            panic(false, "pmm: FreePages failure (%X)", (uint64_t)status);
         }
     }
 
diff --git a/common/protos/chainload.c b/common/protos/chainload.c
index 0e765ebc..a5512f46 100644
--- a/common/protos/chainload.c
+++ b/common/protos/chainload.c
@@ -329,7 +329,7 @@ noreturn void chainload(char *config, char *cmdline) {
                             (EFI_DEVICE_PATH *)memdev_path,
                             ptr, image_size, &new_handle);
     if (status) {
-        panic(false, "efi: LoadImage failure (%x)", status);
+        panic(false, "efi: LoadImage failure (%X)", (uint64_t)status);
     }
 
     EFI_GUID loaded_img_prot_guid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
@@ -338,7 +338,7 @@ noreturn void chainload(char *config, char *cmdline) {
     status = gBS->HandleProtocol(new_handle, &loaded_img_prot_guid,
                                  (void **)&new_handle_loaded_image);
     if (status) {
-        panic(false, "efi: HandleProtocol failure (%x)", status);
+        panic(false, "efi: HandleProtocol failure (%X)", (uint64_t)status);
     }
 
     if (efi_part_handle != 0) {
@@ -358,7 +358,7 @@ noreturn void chainload(char *config, char *cmdline) {
 
     status = gBS->Exit(efi_image_handle, exit_status, exit_data_size, exit_data);
     if (status) {
-        panic(false, "efi: Exit failure (%x)", status);
+        panic(false, "efi: Exit failure (%X)", (uint64_t)status);
     }
 
     __builtin_unreachable();
diff --git a/common/protos/limine.c b/common/protos/limine.c
index 993d72bb..959261fb 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -632,7 +632,7 @@ noreturn void limine_load(char *config, char *cmdline) {
     printv("limine: Slide:           %X\n", slide);
     printv("limine: ELF entry point: %X\n", entry_point);
     printv("limine: Base revision:   %u\n", base_revision);
-    printv("limine: Requests count:  %u\n", requests_count);
+    printv("limine: Requests count:  %U\n", (uint64_t)requests_count);
     printv("limine: Top of HHDM:     %X\n", hhdm_span_top);
 
     // Paging Mode
diff --git a/common/protos/linux_risc.c b/common/protos/linux_risc.c
index 3667b05e..5b1951d8 100644
--- a/common/protos/linux_risc.c
+++ b/common/protos/linux_risc.c
@@ -369,7 +369,7 @@ static void prepare_mmap(struct boot_param *p) {
 
 noreturn static void jump_to_kernel(struct boot_param *p) {
 #if defined(__riscv)
-    printv("linux: bsp hart %d, device tree blob at %p\n", bsp_hartid, p->dtb);
+    printv("linux: bsp hart %U, device tree blob at %p\n", (uint64_t)bsp_hartid, p->dtb);
 
     void (*kernel_entry)(uint64_t hartid, uint64_t dtb) = p->kernel_base;
     asm ("csrci   sstatus, 0x2\n\t"
diff --git a/common/pxe/tftp.s2.c b/common/pxe/tftp.s2.c
index 36d2e2f1..89474b0d 100644
--- a/common/pxe/tftp.s2.c
+++ b/common/pxe/tftp.s2.c
@@ -230,7 +230,7 @@ struct file_handle *tftp_open(struct volume *part, const char *server_addr, cons
 
     // Validate file size from TFTP server (max 1GB)
     if (file_size == 0 || file_size > (1024 * 1024 * 1024)) {
-        print("tftp: Invalid file size from server: %llu\n", (unsigned long long)file_size);
+        print("tftp: Invalid file size from server: %U\n", file_size);
         return NULL;
     }
 
diff --git a/common/sys/cpu_riscv.c b/common/sys/cpu_riscv.c
index 1c141e66..4bdb0541 100644
--- a/common/sys/cpu_riscv.c
+++ b/common/sys/cpu_riscv.c
@@ -71,7 +71,7 @@ static struct riscv_hart *riscv_get_hart(size_t hartid) {
             return hart;
         }
     }
-    panic(false, "no `struct riscv_hart` for hartid %u", hartid);
+    panic(false, "no `struct riscv_hart` for hartid %U", (uint64_t)hartid);
 }
 
 static inline struct rhct_hart_info *rhct_get_hart_info(struct rhct *rhct, uint32_t acpi_uid) {
@@ -120,7 +120,7 @@ static void init_riscv_acpi(void) {
 
         struct rhct_hart_info *hart_info = rhct_get_hart_info(rhct, acpi_uid);
         if (hart_info == NULL) {
-            panic(false, "riscv: missing rhct node for hartid %u", hartid);
+            panic(false, "riscv: missing rhct node for hartid %U", (uint64_t)hartid);
         }
 
         const char *isa_string = NULL;
@@ -162,12 +162,12 @@ static void init_riscv_acpi(void) {
         }
 
         if (isa_string == NULL) {
-            print("riscv: missing isa string for hartid %u, skipping.\n", hartid);
+            print("riscv: missing isa string for hartid %U, skipping.\n", (uint64_t)hartid);
             continue;
         }
 
         if (strncmp("rv64", isa_string, 4) && strncmp("rv32", isa_string, 4)) {
-            print("riscv: skipping hartid %u with invalid isa string: %s\n", hartid, isa_string);
+            print("riscv: skipping hartid %U with invalid isa string: %s\n", (uint64_t)hartid, isa_string);
             continue;
         }
 
@@ -231,12 +231,12 @@ static void init_riscv_fdt(const void *fdt) {
 
         const char *isa_string = fdt_getprop(fdt, node, "riscv,isa", NULL);
         if (isa_string == NULL) {
-            print("riscv: missing isa string for hartid %u, skipping.\n", hartid);
+            print("riscv: missing isa string for hartid %U, skipping.\n", (uint64_t)hartid);
             continue;
         }
 
         if (strncmp("rv64", isa_string, 4) && strncmp("rv32", isa_string, 4)) {
-            print("riscv: skipping hartid %u with invalid isa string: %s\n", hartid, isa_string);
+            print("riscv: skipping hartid %U with invalid isa string: %s\n", (uint64_t)hartid, isa_string);
             continue;
         }
 
diff --git a/common/sys/smp.c b/common/sys/smp.c
index bd33f1d4..75c29390 100644
--- a/common/sys/smp.c
+++ b/common/sys/smp.c
@@ -831,7 +831,7 @@ struct limine_mp_info *init_smp(size_t *cpu_count, pagemap_t pagemap, uint64_t h
             continue;
         }
 
-        printv("smp: Found candidate AP for bring-up. Hart ID: %u\n", hart->hartid);
+        printv("smp: Found candidate AP for bring-up. Hart ID: %U\n", (uint64_t)hart->hartid);
 
         // Try to start the AP.
         size_t satp = make_satp(pagemap.paging_mode, pagemap.top_level);
tab: 248 wrap: offon