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 e66579f89f6e9f52bcc8ae50d7c25744b62de6ef
Author: zhaohaiyang1 <[email protected]>
AuthorDate: Mon Jul 27 15:15:29 2026 +0800

    net/udp: initialize datalen to fix MISRA Rule 9.1 violation
    
    In udp_readahead(), local variable datalen is declared without
    initialization at line 188. Although it is immediately written via
    iob_copyout((FAR uint8_t *)&datalen, ...) through a pointer cast,
    Coverity cannot track pointer-based writes and reports the variable
    as potentially uninitialized when used at line 229 in
    MIN(pstate->ir_msg->msg_iov->iov_len, datalen).
    
    Add zero initialization at declaration to satisfy MISRA C-2012
    Rule 9.1 (Initializers). No behavioral change since iob_copyout
    always writes the value before use.
    
    Coverity CID: 3934100
    Checker: MISRA C-2012 Rule 9.1 (Initializers)
    File: net/udp/udp_recvfrom.c
    
    Signed-off-by: zhaohaiyang1 <[email protected]>
---
 net/udp/udp_recvfrom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/udp/udp_recvfrom.c b/net/udp/udp_recvfrom.c
index c90f5e290e8..6a7db936ba9 100644
--- a/net/udp/udp_recvfrom.c
+++ b/net/udp/udp_recvfrom.c
@@ -163,7 +163,7 @@ static inline void udp_readahead(struct udp_recvfrom_s 
*pstate)
       int recvlen;
       int offset = 0;
       int pos;
-      uint16_t datalen;
+      uint16_t datalen = 0;
       uint8_t src_addr_size;
       uint8_t ifindex;
       uint8_t meta[UDP_READAHEAD_META_SIZE];

Reply via email to