From f4a220b3f9b89ab6de51c6395c9cc9456178e5a0 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Mon, 5 Sep 2022 10:55:29 +0800 Subject: [PATCH] gdbstub: fixed build-error due to potentially uninitialized variable on -O2 Closes https://github.com/espressif/esp-idf/issues/9706 --- components/esp_gdbstub/src/gdbstub.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/esp_gdbstub/src/gdbstub.c b/components/esp_gdbstub/src/gdbstub.c index 7ce49c63ac..cc5288aafd 100644 --- a/components/esp_gdbstub/src/gdbstub.c +++ b/components/esp_gdbstub/src/gdbstub.c @@ -847,7 +847,7 @@ static bool get_task_handle(size_t index, TaskHandle_t *handle) static eTaskState get_task_state(size_t index) { eTaskState result = eReady; - TaskHandle_t handle; + TaskHandle_t handle = NULL; get_task_handle(index, &handle); if (gdb_debug_int == false) { result = eTaskGetState(handle); @@ -858,7 +858,9 @@ static eTaskState get_task_state(size_t index) static int get_task_cpu_id(size_t index) { TaskHandle_t handle; - get_task_handle(index, &handle); + if (!get_task_handle(index, &handle)) { + return -1; + } BaseType_t core_id = xTaskGetAffinity(handle); return (int)core_id; }