This is an automated email from Gerrit.

"Name of user not set <niklaus.leu...@gmail.com>" just uploaded a new patch set 
to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9078

-- gerrit

commit c11cfcd0293cf12181dd05e152b48f90993e70d2
Author: NikLeberg <niklaus.leu...@gmail.com>
Date:   Mon Aug 11 13:19:08 2025 +0200

    jtag/drivers/jtag_dpi: fix wraparound bug in runtest
    
    Commit #0847a4d introduced bug when changing loop variable from `int` to
    `unsigned int`. Instead of getting negative and terminating the loop,
    the value wraps around to `INT_MAX` and the loop never finishes.
    
    Change-Id: I055025a1f8eb4abe50955607b3e89530dfd92af4
    Signed-off-by: NikLeberg <niklaus.leu...@gmail.com>
    Fixes: 0847a4d

diff --git a/src/jtag/drivers/jtag_dpi.c b/src/jtag/drivers/jtag_dpi.c
index d6418d39c7..35dd245072 100644
--- a/src/jtag/drivers/jtag_dpi.c
+++ b/src/jtag/drivers/jtag_dpi.c
@@ -189,7 +189,7 @@ static int jtag_dpi_runtest(unsigned int num_cycles)
                return ERROR_FAIL;
        }
        snprintf(buf, sizeof(buf), "ib %d\n", num_bits);
-       while (num_cycles > 0) {
+       for (unsigned int cycle = 0; cycle < num_cycles; cycle += num_bits + 6) 
{
                ret = write_sock(buf, strlen(buf));
                if (ret != ERROR_OK) {
                        LOG_ERROR("write_sock() fail, file %s, line %d",
@@ -208,8 +208,6 @@ static int jtag_dpi_runtest(unsigned int num_cycles)
                                __FILE__, __LINE__);
                        goto out;
                }
-
-               num_cycles -= num_bits + 6;
        }
 
 out:

-- 

Reply via email to