From 49e75c74d5572d49f575603ceae2b65ef9b08a81 Mon Sep 17 00:00:00 2001 From: Mark O'Donovan Date: Tue, 24 Feb 2026 20:37:06 +0000 Subject: [PATCH] rtos/hwthread: move pointer deref after NULL check Move pointer deref after NULL check. Found by cppcheck. Change-Id: I41b20a0598da83b6d7e353042b6f69e7a58706fc Signed-off-by: Mark O'Donovan Reviewed-on: https://review.openocd.org/c/openocd/+/9501 Reviewed-by: Antonio Borneo Tested-by: jenkins --- src/rtos/hwthread.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rtos/hwthread.c b/src/rtos/hwthread.c index d422fac53..9367f70af 100644 --- a/src/rtos/hwthread.c +++ b/src/rtos/hwthread.c @@ -94,12 +94,13 @@ static int hwthread_update_threads(struct rtos *rtos) struct target_list *head; struct target *target; int64_t current_thread = 0; - int64_t current_threadid = rtos->current_threadid; /* thread selected by GDB */ + int64_t current_threadid; enum target_debug_reason current_reason = DBG_REASON_UNDEFINED; if (!rtos) return -1; + current_threadid = rtos->current_threadid; /* thread selected by GDB */ target = rtos->target; /* wipe out previous thread details if any */