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 <ycsin@meta.com>
This commit is contained in:
Yong Cong Sin 2024-05-26 16:00:05 +08:00 committed by Henrik Brix Andersen
commit 602c993799

View file

@ -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;