diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2021-07-03 18:51:20 +0200 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2021-07-24 10:37:49 +0100 |
commit | 08ee7bb982b16742f52cfdc6c649d82ffa2eb177 (patch) | |
tree | a824d376b774499303f00cffb201e35b01830d98 /src/jtag/aice/aice_usb.c | |
parent | b159f5cdedd70fff9309722e927be670845f4df5 (diff) | |
download | riscv-openocd-08ee7bb982b16742f52cfdc6c649d82ffa2eb177.zip riscv-openocd-08ee7bb982b16742f52cfdc6c649d82ffa2eb177.tar.gz riscv-openocd-08ee7bb982b16742f52cfdc6c649d82ffa2eb177.tar.bz2 |
openocd: fix simple cases of NULL comparison
There are more than 1000 NULL comparisons to be aligned to the
coding style.
For recurrent NULL comparison it's preferable using trivial
scripts in order to minimize the review effort.
Patch generated automatically with the command:
sed -i PATTERN $(find src/ -type f)
where PATTERN is in the list:
's/(\([a-z][a-z0-9_]*\) == NULL)/(!\1)/g'
's/(\([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\) == NULL)/(!\1)/g'
's/(\([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\) == NULL)/(!\1)/g'
's/(\([a-z][a-z0-9_]*\) != NULL)/(\1)/g'
's/(\([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\) != NULL)/(\1)/g'
's/(\([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\) != NULL)/(\1)/g'
's/(NULL == \([a-z][a-z0-9_]*\))/(!\1)/g'
's/(NULL == \([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\))/(!\1)/g'
's/(NULL == \([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\))/(!\1)/g'
's/(NULL != \([a-z][a-z0-9_]*\))/(\1)/g'
's/(NULL != \([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\))/(\1)/g'
's/(NULL != \([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\))/(\1)/g'
Change-Id: Ida103e325d6d0600fb69c0b7a1557ee969db4417
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6350
Tested-by: jenkins
Diffstat (limited to 'src/jtag/aice/aice_usb.c')
-rw-r--r-- | src/jtag/aice/aice_usb.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/jtag/aice/aice_usb.c b/src/jtag/aice/aice_usb.c index f0bb6cc..8d7f38b 100644 --- a/src/jtag/aice/aice_usb.c +++ b/src/jtag/aice/aice_usb.c @@ -2215,24 +2215,24 @@ static int aice_execute_custom_script(const char *script) bool set_op; script_fd = fopen(script, "r"); - if (script_fd == NULL) { + if (!script_fd) { return ERROR_FAIL; } else { while (fgets(line_buffer, LINE_BUFFER_SIZE, script_fd) != NULL) { /* execute operations */ set_op = false; op_str = strstr(line_buffer, "set"); - if (op_str != NULL) { + if (op_str) { set_op = true; goto get_reset_type; } op_str = strstr(line_buffer, "clear"); - if (op_str == NULL) + if (!op_str) continue; get_reset_type: reset_str = strstr(op_str, "srst"); - if (reset_str != NULL) { + if (reset_str) { if (set_op) write_ctrl_value = AICE_CUSTOM_DELAY_SET_SRST; else @@ -2240,7 +2240,7 @@ get_reset_type: goto get_delay; } reset_str = strstr(op_str, "dbgi"); - if (reset_str != NULL) { + if (reset_str) { if (set_op) write_ctrl_value = AICE_CUSTOM_DELAY_SET_DBGI; else @@ -2248,7 +2248,7 @@ get_reset_type: goto get_delay; } reset_str = strstr(op_str, "trst"); - if (reset_str != NULL) { + if (reset_str) { if (set_op) write_ctrl_value = AICE_CUSTOM_DELAY_SET_TRST; else @@ -2732,7 +2732,7 @@ static int aice_usb_reset(void) return ERROR_FAIL; /* issue TRST */ - if (custom_trst_script == NULL) { + if (!custom_trst_script) { if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL, AICE_JTAG_PIN_CONTROL_TRST) != ERROR_OK) return ERROR_FAIL; @@ -2755,7 +2755,7 @@ static int aice_issue_srst(uint32_t coreid) /* After issuing srst, target will be running. So we need to restore EDM_CTL. */ aice_restore_edm_registers(coreid); - if (custom_srst_script == NULL) { + if (!custom_srst_script) { if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL, AICE_JTAG_PIN_CONTROL_SRST) != ERROR_OK) return ERROR_FAIL; @@ -2799,7 +2799,7 @@ static int aice_issue_reset_hold(uint32_t coreid) aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_STATUS, pin_status & (~0x4)); /* issue restart */ - if (custom_restart_script == NULL) { + if (!custom_restart_script) { if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL, AICE_JTAG_PIN_CONTROL_RESTART) != ERROR_OK) return ERROR_FAIL; @@ -2819,7 +2819,7 @@ static int aice_issue_reset_hold(uint32_t coreid) aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_STATUS, pin_status | 0x4); /* issue restart again */ - if (custom_restart_script == NULL) { + if (!custom_restart_script) { if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL, AICE_JTAG_PIN_CONTROL_RESTART) != ERROR_OK) return ERROR_FAIL; @@ -3721,7 +3721,7 @@ static int aice_usb_program_edm(uint32_t coreid, char *command_sequence) /* init strtok() */ command_str = strtok(command_sequence, ";"); - if (command_str == NULL) + if (!command_str) return ERROR_OK; do { @@ -3740,14 +3740,14 @@ static int aice_usb_program_edm(uint32_t coreid, char *command_sequence) reg_name_0 = strstr(command_str, "gen_port0"); reg_name_1 = strstr(command_str, "gen_port1"); - if (reg_name_0 != NULL) { + if (reg_name_0) { data_value = strtoul(reg_name_0 + 9, NULL, 0); if (aice_write_misc(coreid, NDS_EDM_MISC_GEN_PORT0, data_value) != ERROR_OK) return ERROR_FAIL; - } else if (reg_name_1 != NULL) { + } else if (reg_name_1) { data_value = strtoul(reg_name_1 + 9, NULL, 0); if (aice_write_misc(coreid, @@ -3763,7 +3763,7 @@ static int aice_usb_program_edm(uint32_t coreid, char *command_sequence) /* update command_str */ command_str = strtok(NULL, ";"); - } while (command_str != NULL); + } while (command_str); return ERROR_OK; } |