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/+/9070

-- gerrit

commit 3304d3074bbacd4d8fcf2886ef0a0e28f92687f5
Author: Antonio Borneo <borneo.anto...@gmail.com>
Date:   Mon Aug 4 17:42:22 2025 +0200

    openocd: don't test 'debug_level' directly
    
    Use the macro 'LOG_LEVEL_IS()' to test 'debug_level'.
    
    While there, use the macro 'LOG_LVL_*' in place of the numeric
    value.
    
    Skip all riscv code, as it is going to be updated soon from the
    external fork.
    
    Change-Id: Icad7e879e040d3b9cf1cc004c433f28725017493
    Signed-off-by: Antonio Borneo <borneo.anto...@gmail.com>

diff --git a/src/helper/command.c b/src/helper/command.c
index b70081a4dd..f785e79b07 100644
--- a/src/helper/command.c
+++ b/src/helper/command.c
@@ -73,7 +73,7 @@ extern struct command_context *global_cmd_ctx;
  * Do nothing in case we are not at debug level 3 */
 static void script_debug(Jim_Interp *interp, unsigned int argc, Jim_Obj * 
const *argv)
 {
-       if (debug_level < LOG_LVL_DEBUG)
+       if (!LOG_LEVEL_IS(LOG_LVL_DEBUG))
                return;
 
        char *dbg = alloc_printf("command -");
diff --git a/src/helper/log.c b/src/helper/log.c
index d8c4e09ac7..2dada3540e 100644
--- a/src/helper/log.c
+++ b/src/helper/log.c
@@ -113,7 +113,7 @@ static void log_puts(enum log_levels level,
        if (f)
                file = f + 1;
 
-       if (debug_level >= LOG_LVL_DEBUG) {
+       if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) {
                /* print with count and time information */
                int64_t t = timeval_ms() - start;
 #ifdef _DEBUG_FREE_SPACE_
diff --git a/src/helper/log.h b/src/helper/log.h
index ac24f8e833..474d082ede 100644
--- a/src/helper/log.h
+++ b/src/helper/log.h
@@ -101,7 +101,7 @@ extern int debug_level;
 
 #define LOG_DEBUG_IO(expr ...) \
        do { \
-               if (debug_level >= LOG_LVL_DEBUG_IO) \
+               if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO)) \
                        log_printf_lf(LOG_LVL_DEBUG, \
                                __FILE__, __LINE__, __func__, \
                                expr); \
@@ -109,7 +109,7 @@ extern int debug_level;
 
 #define LOG_DEBUG(expr ...) \
        do { \
-               if (debug_level >= LOG_LVL_DEBUG) \
+               if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) \
                        log_printf_lf(LOG_LVL_DEBUG, \
                                __FILE__, __LINE__, __func__, \
                                expr); \
@@ -118,7 +118,7 @@ extern int debug_level;
 #define LOG_CUSTOM_LEVEL(level, expr ...) \
        do { \
                enum log_levels _level = level; \
-               if (debug_level >= _level) \
+               if (LOG_LEVEL_IS(_level)) \
                        log_printf_lf(_level, \
                                __FILE__, __LINE__, __func__, \
                                expr); \
diff --git a/src/jtag/core.c b/src/jtag/core.c
index 6dd2144c63..4a5e096758 100644
--- a/src/jtag/core.c
+++ b/src/jtag/core.c
@@ -967,7 +967,7 @@ int default_interface_jtag_execute_queue(void)
        struct jtag_command *cmd = jtag_command_queue_get();
        int result = adapter_driver->jtag_ops->execute_queue(cmd);
 
-       while (debug_level >= LOG_LVL_DEBUG_IO && cmd) {
+       while (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO) && cmd) {
                switch (cmd->type) {
                        case JTAG_SCAN:
                                LOG_DEBUG_IO("JTAG %s SCAN to %s",
diff --git a/src/rtos/ecos.c b/src/rtos/ecos.c
index a70084b4fb..9539852992 100644
--- a/src/rtos/ecos.c
+++ b/src/rtos/ecos.c
@@ -539,7 +539,7 @@ static int ecos_check_app_info(struct rtos *rtos, struct 
ecos_params *param)
                return -1;
 
        if (param->flush_common) {
-               if (debug_level >= LOG_LVL_DEBUG) {
+               if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) {
                        for (unsigned int idx = 0; idx < 
ARRAY_SIZE(ecos_symbol_list); idx++) {
                                LOG_DEBUG("eCos: %s 0x%016" PRIX64 " %s",
                                        rtos->symbols[idx].optional ? 
"OPTIONAL" : "        ",
diff --git a/src/svf/svf.c b/src/svf/svf.c
index ce994686f1..bcebcbe399 100644
--- a/src/svf/svf.c
+++ b/src/svf/svf.c
@@ -1604,7 +1604,7 @@ xxr_common:
                        LOG_USER("(Above Padding command skipped, as per -tap 
argument)");
        }
 
-       if (debug_level >= LOG_LVL_DEBUG) {
+       if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) {
                /* for convenient debugging, execute tap if possible */
                if ((svf_buffer_index > 0) &&
                                (((command != STATE) && (command != RUNTEST)) ||
diff --git a/src/target/arc.c b/src/target/arc.c
index f2482c25ef..4a6303fbeb 100644
--- a/src/target/arc.c
+++ b/src/target/arc.c
@@ -769,7 +769,7 @@ static int arc_exit_debug(struct target *target)
        target->state = TARGET_HALTED;
        CHECK_RETVAL(target_call_event_callbacks(target, TARGET_EVENT_HALTED));
 
-       if (debug_level >= LOG_LVL_DEBUG) {
+       if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) {
                LOG_TARGET_DEBUG(target, "core stopped (halted) debug-reg: 
0x%08" PRIx32, value);
                CHECK_RETVAL(arc_jtag_read_aux_reg_one(&arc->jtag_info, 
AUX_STATUS32_REG, &value));
                LOG_TARGET_DEBUG(target, "core STATUS32: 0x%08" PRIx32, value);
@@ -824,7 +824,7 @@ static int arc_halt(struct target *target)
        CHECK_RETVAL(target_call_event_callbacks(target, TARGET_EVENT_HALTED));
 
        /* some more debug information */
-       if (debug_level >= LOG_LVL_DEBUG) {
+       if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) {
                LOG_TARGET_DEBUG(target, "core stopped (halted) DEGUB-REG: 
0x%08" PRIx32, value);
                CHECK_RETVAL(arc_get_register_value(target, "status32", 
&value));
                LOG_TARGET_DEBUG(target, "core STATUS32: 0x%08" PRIx32, value);
@@ -1148,7 +1148,7 @@ static int arc_arch_state(struct target *target)
 {
        uint32_t pc_value;
 
-       if (debug_level < LOG_LVL_DEBUG)
+       if (!LOG_LEVEL_IS(LOG_LVL_DEBUG))
                return ERROR_OK;
 
        CHECK_RETVAL(arc_get_register_value(target, "pc", &pc_value));
diff --git a/src/target/arm720t.c b/src/target/arm720t.c
index 702d6cfb10..ddb91ff39f 100644
--- a/src/target/arm720t.c
+++ b/src/target/arm720t.c
@@ -323,7 +323,7 @@ static int arm720t_soft_reset_halt(struct target *target)
                                return retval;
                } else
                        break;
-               if (debug_level >= 3)
+               if (LOG_LEVEL_IS(LOG_LVL_DEBUG))
                        alive_sleep(100);
                else
                        keep_alive();
diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c
index 5550fb1e24..60a9155176 100644
--- a/src/target/arm7_9_common.c
+++ b/src/target/arm7_9_common.c
@@ -637,7 +637,7 @@ int arm7_9_execute_sys_speed(struct target *target)
                if ((buf_get_u32(dbg_stat->value, EICE_DBG_STATUS_DBGACK, 1))
                                && (buf_get_u32(dbg_stat->value, 
EICE_DBG_STATUS_SYSCOMP, 1)))
                        break;
-               if (debug_level >= 3)
+               if (LOG_LEVEL_IS(LOG_LVL_DEBUG))
                        alive_sleep(100);
                else
                        keep_alive();
@@ -1088,7 +1088,7 @@ int arm7_9_soft_reset_halt(struct target *target)
                retval = jtag_execute_queue();
                if (retval != ERROR_OK)
                        return retval;
-               if (debug_level >= 3)
+               if (LOG_LEVEL_IS(LOG_LVL_DEBUG))
                        alive_sleep(100);
                else
                        keep_alive();
diff --git a/src/target/arm920t.c b/src/target/arm920t.c
index 67c212e0bf..441e423054 100644
--- a/src/target/arm920t.c
+++ b/src/target/arm920t.c
@@ -746,7 +746,7 @@ int arm920t_soft_reset_halt(struct target *target)
                                return retval;
                } else
                        break;
-               if (debug_level >= 3) {
+               if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) {
                        /* do not eat all CPU, time out after 1 se*/
                        alive_sleep(100);
                } else
diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c
index a3fff2ae5e..560109228b 100644
--- a/src/target/arm926ejs.c
+++ b/src/target/arm926ejs.c
@@ -544,7 +544,7 @@ int arm926ejs_soft_reset_halt(struct target *target)
                                return retval;
                } else
                        break;
-               if (debug_level >= 1) {
+               if (LOG_LEVEL_IS(LOG_LVL_WARNING)) {
                        /* do not eat all CPU, time out after 1 se*/
                        alive_sleep(100);
                } else
diff --git a/src/target/xscale.c b/src/target/xscale.c
index 50e03f202e..ccaaceb763 100644
--- a/src/target/xscale.c
+++ b/src/target/xscale.c
@@ -400,7 +400,7 @@ static int xscale_read_tx(struct target *target, int 
consume)
                }
                if (!((!(field0_in & 1)) && consume))
                        goto done;
-               if (debug_level >= 3) {
+               if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) {
                        LOG_DEBUG("waiting 100ms");
                        alive_sleep(100);       /* avoid flooding the logs */
                } else
@@ -471,7 +471,7 @@ static int xscale_write_rx(struct target *target)
                }
                if (!(field0_in & 1))
                        goto done;
-               if (debug_level >= 3) {
+               if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) {
                        LOG_DEBUG("waiting 100ms");
                        alive_sleep(100);       /* avoid flooding the logs */
                } else

-- 

Reply via email to