[PATCH] kdb: Avoid array subscript warnings on non-SMP builds

From: Daniel Thompson
Date: Fri Oct 11 2019 - 03:49:29 EST


Recent versions of gcc (reported on gcc-7.4) issue array subscript
warnings for builds where SMP is not enabled.

There is no bug here but there is scope to improve the code
generation for non-SMP systems (whilst also silencing the warning).

Reported-by: kbuild test robot <lkp@xxxxxxxxx>
Fixes: 2277b492582d ("kdb: Fix stack crawling on 'running' CPUs that aren't the master")
Signed-off-by: Daniel Thompson <daniel.thompson@xxxxxxxxxx>
---
kernel/debug/debug_core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
index 70e86b4b4932..eccb7298a0b5 100644
--- a/kernel/debug/debug_core.c
+++ b/kernel/debug/debug_core.c
@@ -449,7 +449,8 @@ void kdb_dump_stack_on_cpu(int cpu)
return;
}

- if (!(kgdb_info[cpu].exception_state & DCPU_IS_SLAVE)) {
+ if (!IS_ENABLED(CONFIG_SMP) ||
+ !(kgdb_info[cpu].exception_state & DCPU_IS_SLAVE)) {
kdb_printf("ERROR: Task on cpu %d didn't stop in the debugger\n",
cpu);
return;
--
2.21.0