This is an automated email from Gerrit.

"Antonio Borneo <borneo.anto...@gmail.com>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/7590

-- gerrit

commit 5ace4979056abc05b80b7ca324f96eb29eda51c3
Author: Antonio Borneo <borneo.anto...@gmail.com>
Date:   Sat Apr 8 23:02:13 2023 +0200

    jtag: vdebug: fix incorrect condition
    
    The value 'pbuf->waddr' is always true, as it is declared as
            uint8_t waddr[2];
    
    It looks like the author wants to check the amount of bytes to
    transfer and incorrectly checks the pointer in place of the value.
    
    Use the byte count in the condition.
    
    Detected through 'sparse' tool.
    
    Change-Id: Ie54f3e0f6de31f06f7aeef46406934d872667320
    Signed-off-by: Antonio Borneo <borneo.anto...@gmail.com>
    Fixes: f97915f248d7 ("drivers/vdebug: add support for DAP level interface")

diff --git a/src/jtag/drivers/vdebug.c b/src/jtag/drivers/vdebug.c
index 7898e9d9b7..b096667180 100644
--- a/src/jtag/drivers/vdebug.c
+++ b/src/jtag/drivers/vdebug.c
@@ -1125,8 +1125,10 @@ static int vdebug_dap_queue_ap_abort(struct adiv5_dap 
*dap, uint8_t *ack)
 
 static int vdebug_dap_run(struct adiv5_dap *dap)
 {
-       if (pbuf->waddr)
-               return vdebug_run_reg_queue(vdc.hsocket, pbuf, 
le_to_h_u16(pbuf->waddr));
+       unsigned int count = le_to_h_u16(pbuf->waddr);
+
+       if (count)
+               return vdebug_run_reg_queue(vdc.hsocket, pbuf, count);
 
        return ERROR_OK;
 }

-- 

Reply via email to