From 24de37898635fb7df648e046eb051326854c22fe Mon Sep 17 00:00:00 2001 From: Benedikt Schmidt Date: Wed, 4 Oct 2023 10:02:36 +0200 Subject: [PATCH] portability: fix thread function signatures Fix thread function signatures to avoid stack corruption on thread exit. Signed-off-by: Benedikt Schmidt --- subsys/portability/cmsis_rtos_v1/cmsis_thread.c | 4 +++- subsys/portability/cmsis_rtos_v2/thread.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/subsys/portability/cmsis_rtos_v1/cmsis_thread.c b/subsys/portability/cmsis_rtos_v1/cmsis_thread.c index 72570f840b..9887e560af 100644 --- a/subsys/portability/cmsis_rtos_v1/cmsis_thread.c +++ b/subsys/portability/cmsis_rtos_v1/cmsis_thread.c @@ -29,6 +29,8 @@ static inline uint32_t cmsis_to_zephyr_priority(int32_t c_prio) static void zephyr_thread_wrapper(void *arg1, void *arg2, void *arg3) { + ARG_UNUSED(arg2); + void * (*fun_ptr)(void *) = arg3; fun_ptr(arg1); @@ -109,7 +111,7 @@ osThreadId osThreadCreate(const osThreadDef_t *thread_def, void *arg) tid = k_thread_create(&cm_thread[instance], stk_ptr[instance], stacksz, - (k_thread_entry_t)zephyr_thread_wrapper, + zephyr_thread_wrapper, (void *)arg, NULL, thread_def->pthread, prio, 0, K_NO_WAIT); diff --git a/subsys/portability/cmsis_rtos_v2/thread.c b/subsys/portability/cmsis_rtos_v2/thread.c index 22bd693612..f5e9cd6702 100644 --- a/subsys/portability/cmsis_rtos_v2/thread.c +++ b/subsys/portability/cmsis_rtos_v2/thread.c @@ -198,7 +198,7 @@ osThreadId_t osThreadNew(osThreadFunc_t threadfunc, void *arg, (void)k_thread_create(&tid->z_thread, stack, stack_size, - (k_thread_entry_t)zephyr_thread_wrapper, + zephyr_thread_wrapper, (void *)arg, tid, threadfunc, prio, 0, K_NO_WAIT);