aboutsummaryrefslogtreecommitdiff
path: root/src/target/nds32_v2.c
diff options
context:
space:
mode:
authorAntonio Borneo <borneo.antonio@gmail.com>2021-07-03 16:47:35 +0200
committerAntonio Borneo <borneo.antonio@gmail.com>2021-07-20 14:55:24 +0100
commit28c24a5c41c47a66e9310912f88148814f730a25 (patch)
tree803cf52a0c8f5a0687f5c7fef402b08cf337ebac /src/target/nds32_v2.c
parentbba48b057cdc4f26721e06a5310652dcf0e55873 (diff)
downloadriscv-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/nds32_v2.c')
-rw-r--r--src/target/nds32_v2.c20
1 files changed, 10 insertions, 10 deletions
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 */