This is an automated email from the ASF dual-hosted git repository.

archer pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 0d0867484a90063bab7d511df2623f4c83708d8c
Author: Xiang Xiao <xiaoxi...@xiaomi.com>
AuthorDate: Mon Dec 18 19:18:30 2023 +0800

    modem/alt1250: Fix 'inst' may be used uninitialized
    
    In function 'unlock_evtbufinst',
        inlined from 'parse_altcompkt' at modem/alt1250/alt1250.c:919:7,
        inlined from 'altcom_recvthread' at modem/alt1250/alt1250.c:968:21:
    Error: modem/alt1250/alt1250.c:385:3: error: 'inst' may be used 
uninitialized [-Werror=maybe-uninitialized]
      385 |   nxmutex_unlock(&inst->stat_lock);
          |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    modem/alt1250/alt1250.c: In function 'altcom_recvthread':
    modem/alt1250/alt1250.c:822:26: note: 'inst' was declared here
      822 |   FAR alt_evtbuf_inst_t *inst;
          |                          ^~~~
    
    Signed-off-by: Xiang Xiao <xiaoxi...@xiaomi.com>
---
 drivers/modem/alt1250/alt1250.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/modem/alt1250/alt1250.c b/drivers/modem/alt1250/alt1250.c
index 97a4e7e2a7..336f941fd7 100644
--- a/drivers/modem/alt1250/alt1250.c
+++ b/drivers/modem/alt1250/alt1250.c
@@ -819,7 +819,7 @@ static int parse_altcompkt(FAR struct alt1250_dev_s *dev, 
FAR uint8_t *pkt,
   uint16_t cid = parse_cid(h);
   uint16_t tid = parse_tid(h);
   parse_handler_t parser;
-  FAR alt_evtbuf_inst_t *inst;
+  FAR alt_evtbuf_inst_t *inst = NULL;
   FAR void **outparam;
   size_t outparamlen;
 
@@ -912,7 +912,7 @@ static int parse_altcompkt(FAR struct alt1250_dev_s *dev, 
FAR uint8_t *pkt,
           *bitmap = ALT1250_EVTBIT_REPLY;
         }
     }
-  else
+  else if (inst != NULL)
     {
       /* Unlock outparam because it has been updated. */
 

Reply via email to