This is an automated email from Gerrit.

"Name of user not set <[email protected]>" just uploaded a new 
patch set to Gerrit, which you can find at 
https://review.openocd.org/c/openocd/+/9752

-- gerrit

commit 58675ca9abdb6866e7bb9dee73521c5c677d2626
Author: IamBoredashell <[email protected]>
Date:   Tue Jun 23 16:53:03 2026 +0530

    target/riscv: remove RISCV_SCAN_DELAY_MAX
    
    jtag_add_runtest() accepts unsigned int since commit 0847a4d7fb98
    ("jtag/commands: Use 'unsigned int' data type"), so the INT_MAX/2
    overflow guard is no longer necessary. Removed the
    RISCV_SCAN_DELAY_MAX macro, the assert in riscv_scan_set_delay(),
    and the overflow check in riscv_scan_increase_delay(). The latter
    is replaced with a wrapping check to catch genuine unsigned integer
    overflow.
    
    Change-Id: I606316e8f83ba3212538a3c06261b09a4f5e1817
    Signed-off-by: IamBoredashell <[email protected]>

diff --git a/src/target/riscv/batch.h b/src/target/riscv/batch.h
index 5d8b57234e..7274eed0a6 100644
--- a/src/target/riscv/batch.h
+++ b/src/target/riscv/batch.h
@@ -46,13 +46,8 @@ riscv_scan_delay_class_name(enum riscv_scan_delay_class 
delay_class)
 }
 
 /* The scan delay values are passed to "jtag_add_runtest()", which accepts an
- * "int".  Therefore, the passed value should be no greater than "INT_MAX".
- *
- * Since the resulting delay value can be a sum of two individual delays,
- * individual delays are limited to "INT_MAX / 2" to prevent overflow of the
- * final sum.
+ * "unsigned int".
  */
-#define RISCV_SCAN_DELAY_MAX (INT_MAX / 2)
 
 struct riscv_scan_delays {
        unsigned int base_delay;
@@ -82,7 +77,6 @@ riscv_scan_get_delay(const struct riscv_scan_delays *delays,
 static inline void riscv_scan_set_delay(struct riscv_scan_delays *delays,
                enum riscv_scan_delay_class delay_class, unsigned int delay)
 {
-       assert(delay <= RISCV_SCAN_DELAY_MAX);
        LOG_DEBUG("%s delay is set to %u.",
                        riscv_scan_delay_class_name(delay_class), delay);
        switch (delay_class) {
@@ -107,12 +101,8 @@ static inline int riscv_scan_increase_delay(struct 
riscv_scan_delays *delays,
 {
        const unsigned int delay = riscv_scan_get_delay(delays, delay_class);
        const unsigned int delay_step = delay / 10 + 1;
-       if (delay > RISCV_SCAN_DELAY_MAX - delay_step) {
-               /* It's not clear if this issue actually occurs in real
-                * use-cases, so stick with a simple solution until the
-                * first bug report.
-                */
-               LOG_ERROR("Delay for %s (%d) is not increased anymore (maximum 
was reached).",
+       if (delay + delay_step < delay) {
+               LOG_ERROR("Delay for %s (%u) is not increased anymore (maximum 
was reached).",
                                riscv_scan_delay_class_name(delay_class), 
delay);
                return ERROR_FAIL;
        }

-- 

Reply via email to