From e7325ec02ab194a7ea9bc1f415a46e40eb05b845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Mon, 12 Aug 2024 15:09:00 +0200 Subject: [PATCH] riscv_common: Use unsiged long format specifier for printing CSR values The read_csr macro returns the CSR value as a `unsigned long`. However, the format specifier presently treats it as a `uint32_t`. This causes a -Wformat error to be emitted by Clang 18: cpu/riscv_common/irq_arch.c:149:49: error: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Werror,-Wformat] 149 | printf(" mepc: 0x%" PRIx32 "\n", read_csr(mepc)); --- cpu/riscv_common/irq_arch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpu/riscv_common/irq_arch.c b/cpu/riscv_common/irq_arch.c index ebd530f44b..f37b58e550 100644 --- a/cpu/riscv_common/irq_arch.c +++ b/cpu/riscv_common/irq_arch.c @@ -146,8 +146,8 @@ static void handle_trap(uword_t mcause) #ifdef DEVELHELP printf("Unhandled trap:\n"); printf(" mcause: 0x%" PRIx32 "\n", trap); - printf(" mepc: 0x%" PRIx32 "\n", read_csr(mepc)); - printf(" mtval: 0x%" PRIx32 "\n", read_csr(mtval)); + printf(" mepc: 0x%lx\n", read_csr(mepc)); + printf(" mtval: 0x%lx\n", read_csr(mtval)); #endif /* Unknown trap */ core_panic(PANIC_GENERAL_ERROR, "Unhandled trap");