forked from auracaster/openocd
jtag/drivers/jtag_dpi: fix wraparound bug in runtest
Commit0847a4d7fb("jtag/commands: Use 'unsigned int' data type") 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.leuenb@gmail.com> Fixes:0847a4d7fb("jtag/commands: Use 'unsigned int' data type") Reviewed-on: https://review.openocd.org/c/openocd/+/9078 Reviewed-by: Evgeniy Naydanov <eugnay@gmail.com> Reviewed-by: zapb <dev@zapb.de> Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
committed by
Antonio Borneo
parent
461af9b3ab
commit
7487fade75
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user