diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2021-07-03 16:47:35 +0200 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2021-07-20 14:55:24 +0100 |
commit | 28c24a5c41c47a66e9310912f88148814f730a25 (patch) | |
tree | 803cf52a0c8f5a0687f5c7fef402b08cf337ebac /src/target | |
parent | bba48b057cdc4f26721e06a5310652dcf0e55873 (diff) | |
download | riscv-openocd-28c24a5c41c47a66e9310912f88148814f730a25.zip riscv-openocd-28c24a5c41c47a66e9310912f88148814f730a25.tar.gz riscv-openocd-28c24a5c41c47a66e9310912f88148814f730a25.tar.bz2 |
openocd: fix simple cases of Yoda condition
There are ~900 Yoda conditions to be aligned to the coding style.
For recurrent Yoda conditions it's preferable using a trivial
script in order to minimize the review effort.
E.g. comparison of uppercase macro/enum with lowercase variable:
- ...(ERROR_OK == retval)...
+ ...(retval == ERROR_OK)...
Patch generated automatically with the command:
sed -i \
's/(\([A-Z][A-Z0-9_]*\) \([=!]=\) \([a-z][a-z0-9_]*\))/(\3 \2 \1)/g' \
$(find src/ -type f)
While there, remove the braces {} around a single statement block
to prevent warning from checkpatch.
Change-Id: If585b0a4b4578879c87b2dd74d9e0025e275ec6b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6354
Tested-by: jenkins
Reviewed-by: Xiang W <wxjstz@126.com>
Diffstat (limited to 'src/target')
-rw-r--r-- | src/target/arc.c | 8 | ||||
-rw-r--r-- | src/target/arc_mem.c | 2 | ||||
-rw-r--r-- | src/target/arm_cti.c | 4 | ||||
-rw-r--r-- | src/target/arm_dap.c | 2 | ||||
-rw-r--r-- | src/target/arm_tpiu_swo.c | 18 | ||||
-rw-r--r-- | src/target/armv8.c | 2 | ||||
-rw-r--r-- | src/target/cortex_a.c | 6 | ||||
-rw-r--r-- | src/target/etm.c | 2 | ||||
-rw-r--r-- | src/target/mips_m4k.c | 4 | ||||
-rw-r--r-- | src/target/mips_mips64.c | 2 | ||||
-rw-r--r-- | src/target/nds32.c | 14 | ||||
-rw-r--r-- | src/target/nds32_v2.c | 20 | ||||
-rw-r--r-- | src/target/nds32_v3.c | 2 | ||||
-rw-r--r-- | src/target/nds32_v3_common.c | 8 | ||||
-rw-r--r-- | src/target/nds32_v3m.c | 2 | ||||
-rw-r--r-- | src/target/openrisc/jsp_server.c | 4 | ||||
-rw-r--r-- | src/target/smp.c | 2 | ||||
-rw-r--r-- | src/target/target.c | 44 | ||||
-rw-r--r-- | src/target/x86_32_common.c | 2 |
19 files changed, 74 insertions, 74 deletions
diff --git a/src/target/arc.c b/src/target/arc.c index e11cd7d..77c9090 100644 --- a/src/target/arc.c +++ b/src/target/arc.c @@ -866,7 +866,7 @@ static int arc_save_context(struct target *target) /* Read data from target. */ if (core_cnt > 0) { retval = arc_jtag_read_core_reg(&arc->jtag_info, core_addrs, core_cnt, core_values); - if (ERROR_OK != retval) { + if (retval != ERROR_OK) { LOG_ERROR("Attempt to read core registers failed."); retval = ERROR_FAIL; goto exit; @@ -874,7 +874,7 @@ static int arc_save_context(struct target *target) } if (aux_cnt > 0) { retval = arc_jtag_read_aux_reg(&arc->jtag_info, aux_addrs, aux_cnt, aux_values); - if (ERROR_OK != retval) { + if (retval != ERROR_OK) { LOG_ERROR("Attempt to read aux registers failed."); retval = ERROR_FAIL; goto exit; @@ -1197,7 +1197,7 @@ static int arc_restore_context(struct target *target) * Check before write, if aux and core count is greater than 0. */ if (core_cnt > 0) { retval = arc_jtag_write_core_reg(&arc->jtag_info, core_addrs, core_cnt, core_values); - if (ERROR_OK != retval) { + if (retval != ERROR_OK) { LOG_ERROR("Attempt to write to core registers failed."); retval = ERROR_FAIL; goto exit; @@ -1206,7 +1206,7 @@ static int arc_restore_context(struct target *target) if (aux_cnt > 0) { retval = arc_jtag_write_aux_reg(&arc->jtag_info, aux_addrs, aux_cnt, aux_values); - if (ERROR_OK != retval) { + if (retval != ERROR_OK) { LOG_ERROR("Attempt to write to aux registers failed."); retval = ERROR_FAIL; goto exit; diff --git a/src/target/arc_mem.c b/src/target/arc_mem.c index 9676269..81d1ab2 100644 --- a/src/target/arc_mem.c +++ b/src/target/arc_mem.c @@ -281,7 +281,7 @@ int arc_mem_read(struct target *target, target_addr_t address, uint32_t size, /* arc_..._read_mem with size 4/2 returns uint32_t/uint16_t in host */ /* endianness, but byte array should represent target endianness */ - if (ERROR_OK == retval) { + if (retval == ERROR_OK) { switch (size) { case 4: target_buffer_set_u32_array(target, buffer, count, diff --git a/src/target/arm_cti.c b/src/target/arm_cti.c index 30212cb..c168245 100644 --- a/src/target/arm_cti.c +++ b/src/target/arm_cti.c @@ -70,7 +70,7 @@ static int arm_cti_mod_reg_bits(struct arm_cti *self, unsigned int reg, uint32_t /* Read register */ int retval = mem_ap_read_atomic_u32(ap, self->spot.base + reg, &tmp); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return retval; /* clear bitfield */ @@ -508,7 +508,7 @@ static int cti_create(struct jim_getopt_info *goi) COMMAND_REGISTRATION_DONE }; e = register_commands_with_data(cmd_ctx, NULL, cti_commands, cti); - if (ERROR_OK != e) + if (e != ERROR_OK) return JIM_ERR; list_add_tail(&cti->lh, &all_cti); diff --git a/src/target/arm_dap.c b/src/target/arm_dap.c index 87e232a..68297b9 100644 --- a/src/target/arm_dap.c +++ b/src/target/arm_dap.c @@ -269,7 +269,7 @@ static int dap_create(struct jim_getopt_info *goi) dap_commands[0].chain = NULL; e = register_commands_with_data(cmd_ctx, NULL, dap_commands, dap); - if (ERROR_OK != e) + if (e != ERROR_OK) return JIM_ERR; list_add_tail(&dap->lh, &all_dap); diff --git a/src/target/arm_tpiu_swo.c b/src/target/arm_tpiu_swo.c index 6d1e94f..66fd748 100644 --- a/src/target/arm_tpiu_swo.c +++ b/src/target/arm_tpiu_swo.c @@ -887,7 +887,7 @@ static int arm_tpiu_swo_create(Jim_Interp *interp, struct arm_tpiu_swo_object *o COMMAND_REGISTRATION_DONE }; e = register_commands_with_data(cmd_ctx, NULL, obj_commands, obj); - if (ERROR_OK != e) + if (e != ERROR_OK) return JIM_ERR; list_add_tail(&obj->lh, &all_tpiu_swo); @@ -1037,7 +1037,7 @@ COMMAND_HANDLER(handle_tpiu_deprecated_config_command) } unsigned int cmd_idx = 0; - if (CMD_ARGC == cmd_idx) + if (cmd_idx == CMD_ARGC) return ERROR_COMMAND_SYNTAX_ERROR; if (!strcmp(CMD_ARGV[cmd_idx], "disable")) { @@ -1055,18 +1055,18 @@ COMMAND_HANDLER(handle_tpiu_deprecated_config_command) const char *pin_clk = NULL; if (!strcmp(CMD_ARGV[cmd_idx], "internal")) { cmd_idx++; - if (CMD_ARGC == cmd_idx) + if (cmd_idx == CMD_ARGC) return ERROR_COMMAND_SYNTAX_ERROR; output = CMD_ARGV[cmd_idx]; } else if (strcmp(CMD_ARGV[cmd_idx], "external")) return ERROR_COMMAND_SYNTAX_ERROR; cmd_idx++; - if (CMD_ARGC == cmd_idx) + if (cmd_idx == CMD_ARGC) return ERROR_COMMAND_SYNTAX_ERROR; if (!strcmp(CMD_ARGV[cmd_idx], "sync")) { protocol = CMD_ARGV[cmd_idx]; cmd_idx++; - if (CMD_ARGC == cmd_idx) + if (cmd_idx == CMD_ARGC) return ERROR_COMMAND_SYNTAX_ERROR; port_width = CMD_ARGV[cmd_idx]; } else { @@ -1074,20 +1074,20 @@ COMMAND_HANDLER(handle_tpiu_deprecated_config_command) return ERROR_COMMAND_SYNTAX_ERROR; protocol = CMD_ARGV[cmd_idx]; cmd_idx++; - if (CMD_ARGC == cmd_idx) + if (cmd_idx == CMD_ARGC) return ERROR_COMMAND_SYNTAX_ERROR; formatter = CMD_ARGV[cmd_idx]; } cmd_idx++; - if (CMD_ARGC == cmd_idx) + if (cmd_idx == CMD_ARGC) return ERROR_COMMAND_SYNTAX_ERROR; trace_clk = CMD_ARGV[cmd_idx]; cmd_idx++; - if (CMD_ARGC != cmd_idx) { + if (cmd_idx != CMD_ARGC) { pin_clk = CMD_ARGV[cmd_idx]; cmd_idx++; } - if (CMD_ARGC != cmd_idx) + if (cmd_idx != CMD_ARGC) return ERROR_COMMAND_SYNTAX_ERROR; LOG_INFO(MSG "Running: \'%s configure -protocol %s -traceclk %s" "%s%s" "%s%s" "%s%s" "%s%s\'", diff --git a/src/target/armv8.c b/src/target/armv8.c index 50010ef..49e8b10 100644 --- a/src/target/armv8.c +++ b/src/target/armv8.c @@ -1823,7 +1823,7 @@ int armv8_set_dbgreg_bits(struct armv8_common *armv8, unsigned int reg, unsigned /* Read register */ int retval = mem_ap_read_atomic_u32(armv8->debug_ap, armv8->debug_base + reg, &tmp); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return retval; /* clear bitfield */ diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c index 6d13920..faed2d5 100644 --- a/src/target/cortex_a.c +++ b/src/target/cortex_a.c @@ -1138,7 +1138,7 @@ static int cortex_a_set_dscr_bits(struct target *target, /* Read DSCR */ int retval = mem_ap_read_atomic_u32(armv7a->debug_ap, armv7a->debug_base + CPUDBG_DSCR, &dscr); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return retval; /* clear bitfield */ @@ -1197,7 +1197,7 @@ static int cortex_a_step(struct target *target, int current, target_addr_t addre /* Disable interrupts during single step if requested */ if (cortex_a->isrmasking_mode == CORTEX_A_ISRMASK_ON) { retval = cortex_a_set_dscr_bits(target, DSCR_INT_DIS, DSCR_INT_DIS); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return retval; } @@ -1228,7 +1228,7 @@ static int cortex_a_step(struct target *target, int current, target_addr_t addre /* Re-enable interrupts if they were disabled */ if (cortex_a->isrmasking_mode == CORTEX_A_ISRMASK_ON) { retval = cortex_a_set_dscr_bits(target, DSCR_INT_DIS, 0); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return retval; } diff --git a/src/target/etm.c b/src/target/etm.c index 6dc2bd4..8555872 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -1418,7 +1418,7 @@ COMMAND_HANDLER(handle_etm_config_command) if (strcmp(CMD_ARGV[4], etm_capture_drivers[i]->name) == 0) { int retval = register_commands(CMD_CTX, NULL, etm_capture_drivers[i]->commands); - if (ERROR_OK != retval) { + if (retval != ERROR_OK) { free(etm_ctx); return retval; } diff --git a/src/target/mips_m4k.c b/src/target/mips_m4k.c index 249412a..8fa4309 100644 --- a/src/target/mips_m4k.c +++ b/src/target/mips_m4k.c @@ -1061,7 +1061,7 @@ static int mips_m4k_read_memory(struct target *target, target_addr_t address, /* mips32_..._read_mem with size 4/2 returns uint32_t/uint16_t in host */ /* endianness, but byte array should represent target endianness */ - if (ERROR_OK == retval) { + if (retval == ERROR_OK) { switch (size) { case 4: target_buffer_set_u32_array(target, buffer, count, t); @@ -1137,7 +1137,7 @@ static int mips_m4k_write_memory(struct target *target, target_addr_t address, free(t); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return retval; return ERROR_OK; diff --git a/src/target/mips_mips64.c b/src/target/mips_mips64.c index 9ba46b7..56b0194 100644 --- a/src/target/mips_mips64.c +++ b/src/target/mips_mips64.c @@ -923,7 +923,7 @@ static int mips_mips64_read_memory(struct target *target, uint64_t address, retval = mips64_pracc_read_mem(ejtag_info, address, size, count, (void *)t); - if (ERROR_OK != retval) { + if (retval != ERROR_OK) { LOG_ERROR("mips64_pracc_read_mem filed"); goto read_done; } diff --git a/src/target/nds32.c b/src/target/nds32.c index 372f82d..184f2fe 100644 --- a/src/target/nds32.c +++ b/src/target/nds32.c @@ -330,16 +330,16 @@ static int nds32_set_core_reg(struct reg *reg, uint8_t *buf) reg->dirty = false; /* update registers to take effect right now */ - if (IR0 == mapped_regnum) { + if (mapped_regnum == IR0) { nds32_update_psw(nds32); - } else if (MR0 == mapped_regnum) { + } else if (mapped_regnum == MR0) { nds32_update_mmu_info(nds32); - } else if ((MR6 == mapped_regnum) || (MR7 == mapped_regnum)) { + } else if ((mapped_regnum == MR6) || (mapped_regnum == MR7)) { /* update lm information */ nds32_update_lm_info(nds32); - } else if (MR8 == mapped_regnum) { + } else if (mapped_regnum == MR8) { nds32_update_cache_info(nds32); - } else if (FUCPR == mapped_regnum) { + } else if (mapped_regnum == FUCPR) { /* update audio/fpu setting */ nds32_check_extension(nds32); } @@ -1951,7 +1951,7 @@ int nds32_examine_debug_reason(struct nds32 *nds32) nds32_step_without_watchpoint(nds32); /* before single_step, save exception address */ - if (ERROR_OK != result) + if (result != ERROR_OK) return ERROR_FAIL; target->debug_reason = DBG_REASON_WATCHPOINT; @@ -2059,7 +2059,7 @@ int nds32_halt(struct target *target) if (nds32_target_state(nds32, &state) != ERROR_OK) return ERROR_FAIL; - if (TARGET_HALTED != state) + if (state != TARGET_HALTED) /* TODO: if state == TARGET_HALTED, check ETYPE is DBGI or not */ if (ERROR_OK != aice_halt(aice)) return ERROR_FAIL; diff --git a/src/target/nds32_v2.c b/src/target/nds32_v2.c index 392bd6e..8916a59 100644 --- a/src/target/nds32_v2.c +++ b/src/target/nds32_v2.c @@ -37,35 +37,35 @@ static int nds32_v2_register_mapping(struct nds32 *nds32, int reg_no) uint32_t cur_level = nds32->current_interrupt_level; if ((1 <= cur_level) && (cur_level < max_level)) { - if (IR0 == reg_no) { + if (reg_no == IR0) { LOG_DEBUG("Map PSW to IPSW"); return IR1; - } else if (PC == reg_no) { + } else if (reg_no == PC) { LOG_DEBUG("Map PC to IPC"); return IR9; } } else if ((2 <= cur_level) && (cur_level < max_level)) { - if (R26 == reg_no) { + if (reg_no == R26) { LOG_DEBUG("Mapping P0 to P_P0"); return IR12; - } else if (R27 == reg_no) { + } else if (reg_no == R27) { LOG_DEBUG("Mapping P1 to P_P1"); return IR13; - } else if (IR1 == reg_no) { + } else if (reg_no == IR1) { LOG_DEBUG("Mapping IPSW to P_IPSW"); return IR2; - } else if (IR4 == reg_no) { + } else if (reg_no == IR4) { LOG_DEBUG("Mapping EVA to P_EVA"); return IR5; - } else if (IR6 == reg_no) { + } else if (reg_no == IR6) { LOG_DEBUG("Mapping ITYPE to P_ITYPE"); return IR7; - } else if (IR9 == reg_no) { + } else if (reg_no == IR9) { LOG_DEBUG("Mapping IPC to P_IPC"); return IR10; } } else if (cur_level == max_level) { - if (PC == reg_no) { + if (reg_no == PC) { LOG_DEBUG("Mapping PC to O_IPC"); return IR11; } @@ -436,7 +436,7 @@ static int nds32_v2_add_breakpoint(struct target *target, return ERROR_OK; } else if (breakpoint->type == BKPT_SOFT) { result = nds32_add_software_breakpoint(target, breakpoint); - if (ERROR_OK != result) { + if (result != ERROR_OK) { /* auto convert to hardware breakpoint if failed */ if (nds32->auto_convert_hw_bp) { /* convert to hardware breakpoint */ diff --git a/src/target/nds32_v3.c b/src/target/nds32_v3.c index f9cd47a..fde86d6 100644 --- a/src/target/nds32_v3.c +++ b/src/target/nds32_v3.c @@ -310,7 +310,7 @@ static int nds32_v3_add_breakpoint(struct target *target, return ERROR_OK; } else if (breakpoint->type == BKPT_SOFT) { result = nds32_add_software_breakpoint(target, breakpoint); - if (ERROR_OK != result) { + if (result != ERROR_OK) { /* auto convert to hardware breakpoint if failed */ if (nds32->auto_convert_hw_bp) { /* convert to hardware breakpoint */ diff --git a/src/target/nds32_v3_common.c b/src/target/nds32_v3_common.c index 271ffdd..3abb3b9 100644 --- a/src/target/nds32_v3_common.c +++ b/src/target/nds32_v3_common.c @@ -268,8 +268,8 @@ static int nds32_v3_get_exception_address(struct nds32 *nds32, nds32_get_mapped_reg(nds32, PC, &val_pc); - if ((NDS32_DEBUG_DATA_ADDR_WATCHPOINT_NEXT_PRECISE == reason) || - (NDS32_DEBUG_DATA_VALUE_WATCHPOINT_NEXT_PRECISE == reason)) { + if ((reason == NDS32_DEBUG_DATA_ADDR_WATCHPOINT_NEXT_PRECISE) || + (reason == NDS32_DEBUG_DATA_VALUE_WATCHPOINT_NEXT_PRECISE)) { if (edmsw & 0x4) /* check EDMSW.IS_16BIT */ val_pc -= 2; else @@ -320,7 +320,7 @@ static int nds32_v3_get_exception_address(struct nds32 *nds32, return ERROR_FAIL; } else if (match_count == 0) { /* global stop is precise exception */ - if ((NDS32_DEBUG_LOAD_STORE_GLOBAL_STOP == reason) && nds32->global_stop) { + if ((reason == NDS32_DEBUG_LOAD_STORE_GLOBAL_STOP) && nds32->global_stop) { /* parse instruction to get correct access address */ uint32_t val_pc; uint32_t opcode; @@ -553,7 +553,7 @@ int nds32_v3_write_buffer(struct target *target, target_addr_t address, int result; result = nds32_gdb_fileio_write_memory(nds32, address, size, buffer); - if (NDS_MEMORY_ACC_CPU == origin_access_channel) { + if (origin_access_channel == NDS_MEMORY_ACC_CPU) { memory->access_channel = NDS_MEMORY_ACC_CPU; aice_memory_access(aice, NDS_MEMORY_ACC_CPU); } diff --git a/src/target/nds32_v3m.c b/src/target/nds32_v3m.c index 952d0eb..ffd646f 100644 --- a/src/target/nds32_v3m.c +++ b/src/target/nds32_v3m.c @@ -267,7 +267,7 @@ static int nds32_v3m_add_breakpoint(struct target *target, return ERROR_OK; } else if (breakpoint->type == BKPT_SOFT) { result = nds32_add_software_breakpoint(target, breakpoint); - if (ERROR_OK != result) { + if (result != ERROR_OK) { /* auto convert to hardware breakpoint if failed */ if (nds32->auto_convert_hw_bp) { /* convert to hardware breakpoint */ diff --git a/src/target/openrisc/jsp_server.c b/src/target/openrisc/jsp_server.c index 4dbe635..e0a4475 100644 --- a/src/target/openrisc/jsp_server.c +++ b/src/target/openrisc/jsp_server.c @@ -103,7 +103,7 @@ static int jsp_new_connection(struct connection *connection) int retval = target_register_timer_callback(&jsp_poll_read, 1, TARGET_TIMER_TYPE_PERIODIC, jsp_service); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return retval; return ERROR_OK; @@ -187,7 +187,7 @@ static int jsp_connection_closed(struct connection *connection) struct jsp_service *jsp_service = connection->service->priv; int retval = target_unregister_timer_callback(&jsp_poll_read, jsp_service); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return retval; free(connection->priv); diff --git a/src/target/smp.c b/src/target/smp.c index 6501dc0..94c4da5 100644 --- a/src/target/smp.c +++ b/src/target/smp.c @@ -141,7 +141,7 @@ COMMAND_HANDLER(handle_smp_gdb_command) if (CMD_ARGC == 1) { int coreid = 0; COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], coreid); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return retval; target->gdb_service->core[1] = coreid; diff --git a/src/target/target.c b/src/target/target.c index 3772f8e..7dbcadb 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -1546,7 +1546,7 @@ static int target_init_one(struct command_context *cmd_ctx, assert(type->init_target != NULL); int retval = type->init_target(cmd_ctx, target); - if (ERROR_OK != retval) { + if (retval != ERROR_OK) { LOG_ERROR("target '%s' init failed", target_name(target)); return retval; } @@ -1598,7 +1598,7 @@ static int target_init(struct command_context *cmd_ctx) for (target = all_targets; target; target = target->next) { retval = target_init_one(cmd_ctx, target); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return retval; } @@ -1606,12 +1606,12 @@ static int target_init(struct command_context *cmd_ctx) return ERROR_OK; retval = target_register_user_commands(cmd_ctx); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return retval; retval = target_register_timer_callback(&handle_target, polling_interval, TARGET_TIMER_TYPE_PERIODIC, cmd_ctx->interp); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return retval; return ERROR_OK; @@ -1632,15 +1632,15 @@ COMMAND_HANDLER(handle_target_init_command) target_initialized = true; retval = command_run_line(CMD_CTX, "init_targets"); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return retval; retval = command_run_line(CMD_CTX, "init_target_events"); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return retval; retval = command_run_line(CMD_CTX, "init_board"); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return retval; LOG_DEBUG("Initializing targets..."); @@ -3225,7 +3225,7 @@ COMMAND_HANDLER(handle_wait_halt_command) unsigned ms = DEFAULT_HALT_TIMEOUT; if (1 == CMD_ARGC) { int retval = parse_uint(CMD_ARGV[0], &ms); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return ERROR_COMMAND_SYNTAX_ERROR; } @@ -3281,13 +3281,13 @@ COMMAND_HANDLER(handle_halt_command) target->verbose_halt_msg = true; int retval = target_halt(target); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return retval; if (CMD_ARGC == 1) { unsigned wait_local; retval = parse_uint(CMD_ARGV[0], &wait_local); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return ERROR_COMMAND_SYNTAX_ERROR; if (!wait_local) return ERROR_OK; @@ -3482,7 +3482,7 @@ COMMAND_HANDLER(handle_md_command) struct target *target = get_current_target(CMD_CTX); int retval = fn(target, address, size, count, buffer); - if (ERROR_OK == retval) + if (retval == ERROR_OK) target_handle_md_output(CMD, target, address, size, count, buffer); free(buffer); @@ -3639,7 +3639,7 @@ COMMAND_HANDLER(handle_load_image_command) int retval = CALL_COMMAND_HANDLER(parse_load_image_command_CMD_ARGV, &image, &min_address, &max_address); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return retval; struct target *target = get_current_target(CMD_CTX); @@ -3700,7 +3700,7 @@ COMMAND_HANDLER(handle_load_image_command) free(buffer); } - if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) { + if ((retval == ERROR_OK) && (duration_measure(&bench) == ERROR_OK)) { command_print(CMD, "downloaded %" PRIu32 " bytes " "in %fs (%0.3f KiB/s)", image_size, duration_elapsed(&bench), duration_kbps(&bench, image_size)); @@ -3757,7 +3757,7 @@ COMMAND_HANDLER(handle_dump_image_command) free(buffer); - if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) { + if ((retval == ERROR_OK) && (duration_measure(&bench) == ERROR_OK)) { size_t filesize; retval = fileio_size(fileio, &filesize); if (retval != ERROR_OK) @@ -3902,7 +3902,7 @@ static COMMAND_HELPER(handle_verify_image_command_internal, enum verify_mode ver done: if (diffs > 0) retval = ERROR_FAIL; - if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) { + if ((retval == ERROR_OK) && (duration_measure(&bench) == ERROR_OK)) { command_print(CMD, "verified %" PRIu32 " bytes " "in %fs (%0.3f KiB/s)", image_size, duration_elapsed(&bench), duration_kbps(&bench, image_size)); @@ -3972,7 +3972,7 @@ static int handle_bp_command_set(struct command_invocation *cmd, if (asid == 0) { retval = breakpoint_add(target, addr, length, hw); /* error is always logged in breakpoint_add(), do not print it again */ - if (ERROR_OK == retval) + if (retval == ERROR_OK) command_print(cmd, "breakpoint set at " TARGET_ADDR_FMT "", addr); } else if (addr == 0) { @@ -3982,7 +3982,7 @@ static int handle_bp_command_set(struct command_invocation *cmd, } retval = context_breakpoint_add(target, asid, length, hw); /* error is always logged in context_breakpoint_add(), do not print it again */ - if (ERROR_OK == retval) + if (retval == ERROR_OK) command_print(cmd, "Context breakpoint set at 0x%8.8" PRIx32 "", asid); } else { @@ -3992,7 +3992,7 @@ static int handle_bp_command_set(struct command_invocation *cmd, } retval = hybrid_breakpoint_add(target, addr, asid, length, hw); /* error is always logged in hybrid_breakpoint_add(), do not print it again */ - if (ERROR_OK == retval) + if (retval == ERROR_OK) command_print(cmd, "Hybrid breakpoint set at 0x%8.8" PRIx32 "", asid); } return retval; @@ -4123,7 +4123,7 @@ COMMAND_HANDLER(handle_wp_command) int retval = watchpoint_add(target, addr, length, type, data_value, data_mask); - if (ERROR_OK != retval) + if (retval != ERROR_OK) LOG_ERROR("Failure setting watchpoints"); return retval; @@ -5871,7 +5871,7 @@ static int target_create(struct jim_getopt_info *goi) /* create the target specific commands */ if (target->type->commands) { e = register_commands(cmd_ctx, NULL, target->type->commands); - if (ERROR_OK != e) + if (e != ERROR_OK) LOG_ERROR("unable to register '%s' commands", cp); } @@ -6101,7 +6101,7 @@ COMMAND_HANDLER(handle_fast_load_image_command) int retval = CALL_COMMAND_HANDLER(parse_load_image_command_CMD_ARGV, &image, &min_address, &max_address); - if (ERROR_OK != retval) + if (retval != ERROR_OK) return retval; struct duration bench; @@ -6173,7 +6173,7 @@ COMMAND_HANDLER(handle_fast_load_image_command) free(buffer); } - if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) { + if ((retval == ERROR_OK) && (duration_measure(&bench) == ERROR_OK)) { command_print(CMD, "Loaded %" PRIu32 " bytes " "in %fs (%0.3f KiB/s)", image_size, duration_elapsed(&bench), duration_kbps(&bench, image_size)); diff --git a/src/target/x86_32_common.c b/src/target/x86_32_common.c index b85e451..d0b0e37 100644 --- a/src/target/x86_32_common.c +++ b/src/target/x86_32_common.c @@ -1428,7 +1428,7 @@ COMMAND_HANDLER(handle_iod_command) uint8_t *buffer = calloc(count, size); struct target *target = get_current_target(CMD_CTX); int retval = x86_32_common_read_io(target, address, size, buffer); - if (ERROR_OK == retval) + if (retval == ERROR_OK) handle_iod_output(CMD, target, address, size, count, buffer); free(buffer); return retval; |