From 2d475b3dcdfcc9376d75da406280f1bf5997ff5d Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Sun, 16 Nov 2025 23:06:55 +0100 Subject: [PATCH] tests/core/msg_queue_print: fully initialize msg for sending On 8-bit and 16-bit platforms `uint32_t` is wider than `void *`, as pointers are (typically) only 16 bit in size. This causes output like: Message queue of thread 2 size: 8 (avail: 8) * 0: sender: 2, type: 0x0000, content: 2701197312 (0) * 1: sender: 2, type: 0x0001, content: 2701197313 (0x1) As seen here, the leading two bytes of `msg.content.value` contain "random" bits, as those bytes are not explicitly initialized. This fixes the issue by explicitly initializing the whole `msg_t` via an initializer list. --- tests/core/msg_queue_print/main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/core/msg_queue_print/main.c b/tests/core/msg_queue_print/main.c index 40aec733f5..7753e612f1 100644 --- a/tests/core/msg_queue_print/main.c +++ b/tests/core/msg_queue_print/main.c @@ -39,8 +39,10 @@ int main(void) /* fill message queue */ for (uintptr_t i = 0; i < QUEUE_SIZE; i++) { - msg.type = i; - msg.content.ptr = (void *) i; + msg = (msg_t) { + .type = i, + .content.ptr = (void *)i, + }; msg_send_to_self(&msg); } @@ -55,8 +57,10 @@ int main(void) /* fill up message queue again */ for (uintptr_t i = QUEUE_SIZE; i < QUEUE_SIZE + QUEUE_SIZE/2; i++) { - msg.type = i; - msg.content.ptr = (void *) i; + msg = (msg_t) { + .type = i, + .content.ptr = (void *)i, + }; msg_send_to_self(&msg); }