From 0e097b54a40ae0f6c04b5ac4de4144b977921833 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Tue, 22 Sep 2020 14:37:55 +0200 Subject: [PATCH] cpu/cortexm_common: Silence -Wcast-align false positives Verified that each warning generated by -Wcast-align is indeed a false positive and used an (intermediate) cast to `uintptr_t` to silence the warnings. --- cpu/cortexm_common/thread_arch.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cpu/cortexm_common/thread_arch.c b/cpu/cortexm_common/thread_arch.c index dc1e9d51b2..0a4b7c4f84 100644 --- a/cpu/cortexm_common/thread_arch.c +++ b/cpu/cortexm_common/thread_arch.c @@ -238,7 +238,10 @@ char *thread_stack_init(thread_task_func_t task_func, void thread_stack_print(void) { int count = 0; - uint32_t *sp = (uint32_t *)thread_get_active()->sp; + /* The stack pointer will be aligned to word boundary by thread_create, + * which is 32 bit for all Cortex M MCUs. We can silence -Wcast-align here + */ + uint32_t *sp = (uint32_t *)(uintptr_t)thread_get_active()->sp; printf("printing the current stack of thread %" PRIkernel_pid "\n", thread_getpid());