From f93c1ed291c8f3c2eb6c3c7022a1b1a5ebcf085f Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Tue, 21 Jan 2025 21:02:07 -0500 Subject: [PATCH] kernel/pipe: squash compiler warning The compiler complains that: ``` zephyr/kernel/include/kernel_internal.h:121:29: error: 'reader' may be used uninitialized [-Werror=maybe-uninitialized] 121 | thread->swap_retval = value; | ~~~~~~~~~~~~~~~~~~~~^~~~~~~ zephyr/kernel/pipe.c: In function 'copy_to_pending_readers': zephyr/kernel/pipe.c:92:26: note: 'reader' was declared here 92 | struct k_thread *reader; | ^~~~~~ ``` The static analyzer fails to see through the `LOCK_SCHED_SPINLOCK` construct that the `reader` pointer is always initialized. Signed-off-by: Nicolas Pitre --- kernel/pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/pipe.c b/kernel/pipe.c index 6085de180b8..494e84ceb6a 100644 --- a/kernel/pipe.c +++ b/kernel/pipe.c @@ -89,7 +89,7 @@ struct pipe_buf_spec { static size_t copy_to_pending_readers(struct k_pipe *pipe, bool *need_resched, const uint8_t *data, size_t len) { - struct k_thread *reader; + struct k_thread *reader = NULL; struct pipe_buf_spec *reader_buf; size_t copy_size, written = 0;