From 602c99379939af804906621ba97e7ea944310139 Mon Sep 17 00:00:00 2001 From: Yong Cong Sin Date: Sun, 26 May 2024 16:00:05 +0800 Subject: [PATCH] arch: riscv: stacktrace: fix cpuid type and optimize branch with compiler Change the type of `cpu_id` to `uint8_t` since that is the type of `arch_curr_cpu()->id`. Instead of using precompiler switch (`#ifdef CONFIG_SMP`), use if-else shorthand instead (`IS_ENABLED(CONFIG_SMP)`). Signed-off-by: Yong Cong Sin --- arch/riscv/core/stacktrace.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/riscv/core/stacktrace.c b/arch/riscv/core/stacktrace.c index 9c6c013efae..ed0d4c1ba47 100644 --- a/arch/riscv/core/stacktrace.c +++ b/arch/riscv/core/stacktrace.c @@ -49,13 +49,7 @@ static bool in_stack_bound(uintptr_t addr) if (_current == NULL || arch_is_in_isr()) { /* We were servicing an interrupt */ - int cpu_id; - -#ifdef CONFIG_SMP - cpu_id = arch_curr_cpu()->id; -#else - cpu_id = 0; -#endif + uint8_t cpu_id = IS_ENABLED(CONFIG_SMP) ? arch_curr_cpu()->id : 0U; start = (uintptr_t)K_KERNEL_STACK_BUFFER(z_interrupt_stacks[cpu_id]); end = start + CONFIG_ISR_STACK_SIZE;