This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 5f0b2cb96109a1ecb21a6c645fcf66082a881b19 Author: yezhonghui <[email protected]> AuthorDate: Fri May 8 20:55:10 2026 +0800 include/ring: fix maybe-uninitialized warning in ring_buf_init When count is zero, ring_buf_init returns early without initializing ptr1/len1/ptr2/len2. GCC inlines the callers (ring_mp_enqueue, ring_sc_dequeue, etc.) and cannot prove these members are set, triggering -Werror=maybe-uninitialized. Initialize all ring_buf_s members on the zero-count path. Signed-off-by: yezhonghui <[email protected]> --- include/nuttx/ring.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/nuttx/ring.h b/include/nuttx/ring.h index 725423a990b..cb1613e8e05 100644 --- a/include/nuttx/ring.h +++ b/include/nuttx/ring.h @@ -470,6 +470,11 @@ ring_buf_init(FAR struct ring_buf_s *buf, FAR struct ring_s *r, if (count == 0) { + buf->ptr1 = NULL; + buf->len1 = 0; + buf->ptr2 = NULL; + buf->len2 = 0; + buf->idx = 0; return; }
