diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2021-07-03 22:10:55 +0200 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2021-07-24 10:38:19 +0100 |
commit | 54e699b2601036e384a124657aa1fbdd9ff2dc87 (patch) | |
tree | 69bb8d7842b6a8eb23d005fc51a1f414038d99a0 /src/jtag | |
parent | 0a1f904707fa3c170032dd9dba8f2ef9207ff9b2 (diff) | |
download | riscv-openocd-54e699b2601036e384a124657aa1fbdd9ff2dc87.zip riscv-openocd-54e699b2601036e384a124657aa1fbdd9ff2dc87.tar.gz riscv-openocd-54e699b2601036e384a124657aa1fbdd9ff2dc87.tar.bz2 |
openocd: manually remove NULL comparisons
For the remaining NULL comparisons, remove then manually.
While there, make more readable a loop, by moving the assigment
out of the loop condition.
Change-Id: I44193aaa95813156a3a79c16b80e1ad333dc1eaf
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6353
Tested-by: jenkins
Diffstat (limited to 'src/jtag')
-rw-r--r-- | src/jtag/aice/aice_usb.c | 2 | ||||
-rw-r--r-- | src/jtag/core.c | 14 | ||||
-rw-r--r-- | src/jtag/drivers/rlink.c | 21 | ||||
-rw-r--r-- | src/jtag/drivers/vsllink.c | 2 |
4 files changed, 15 insertions, 24 deletions
diff --git a/src/jtag/aice/aice_usb.c b/src/jtag/aice/aice_usb.c index 8d7f38b..53d2838 100644 --- a/src/jtag/aice/aice_usb.c +++ b/src/jtag/aice/aice_usb.c @@ -2218,7 +2218,7 @@ static int aice_execute_custom_script(const char *script) if (!script_fd) { return ERROR_FAIL; } else { - while (fgets(line_buffer, LINE_BUFFER_SIZE, script_fd) != NULL) { + while (fgets(line_buffer, LINE_BUFFER_SIZE, script_fd)) { /* execute operations */ set_op = false; op_str = strstr(line_buffer, "set"); diff --git a/src/jtag/core.c b/src/jtag/core.c index 51c1228..1406238 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -1336,7 +1336,6 @@ out: static int jtag_validate_ircapture(void) { struct jtag_tap *tap; - int total_ir_length = 0; uint8_t *ir_test = NULL; struct scan_field field; uint64_t val; @@ -1344,11 +1343,12 @@ static int jtag_validate_ircapture(void) int retval; /* when autoprobing, accommodate huge IR lengths */ - for (tap = NULL, total_ir_length = 0; - (tap = jtag_tap_next_enabled(tap)) != NULL; - total_ir_length += tap->ir_length) { + int total_ir_length = 0; + for (tap = jtag_tap_next_enabled(NULL); tap; tap = jtag_tap_next_enabled(tap)) { if (tap->ir_length == 0) total_ir_length += JTAG_IRLEN_MAX; + else + total_ir_length += tap->ir_length; } /* increase length to add 2 bit sentinel after scan */ @@ -2008,7 +2008,7 @@ bool transport_is_jtag(void) int adapter_resets(int trst, int srst) { - if (get_current_transport() == NULL) { + if (!get_current_transport()) { LOG_ERROR("transport is not selected"); return ERROR_FAIL; } @@ -2065,7 +2065,7 @@ int adapter_assert_reset(void) transport_is_dapdirect_jtag() || transport_is_dapdirect_swd() || transport_is_swim()) return adapter_system_reset(1); - else if (get_current_transport() != NULL) + else if (get_current_transport()) LOG_ERROR("reset is not supported on %s", get_current_transport()->name); else @@ -2082,7 +2082,7 @@ int adapter_deassert_reset(void) transport_is_dapdirect_jtag() || transport_is_dapdirect_swd() || transport_is_swim()) return adapter_system_reset(0); - else if (get_current_transport() != NULL) + else if (get_current_transport()) LOG_ERROR("reset is not supported on %s", get_current_transport()->name); else diff --git a/src/jtag/drivers/rlink.c b/src/jtag/drivers/rlink.c index 8b6aa3e..f75a38b 100644 --- a/src/jtag/drivers/rlink.c +++ b/src/jtag/drivers/rlink.c @@ -1148,11 +1148,8 @@ static int rlink_scan(struct jtag_command *cmd, enum scan_type type, byte_bits -= chunk_bits; if (type != SCAN_OUT) { - if (dtc_queue_enqueue_reply( - type, buffer, scan_size, tdi_bit_offset, - chunk_bits, - cmd - ) == NULL) { + if (!dtc_queue_enqueue_reply(type, buffer, scan_size, tdi_bit_offset, + chunk_bits, cmd)) { LOG_ERROR("enqueuing DTC reply entry: %s", strerror(errno)); exit(1); } @@ -1208,11 +1205,8 @@ static int rlink_scan(struct jtag_command *cmd, enum scan_type type, * and one reply byte */ dtc_queue_run_if_full(type == SCAN_IN ? 1 : 2, 1); - if (dtc_queue_enqueue_reply( - type, buffer, scan_size, tdi_bit_offset, - extra_bits, - cmd - ) == NULL) { + if (!dtc_queue_enqueue_reply(type, buffer, scan_size, tdi_bit_offset, + extra_bits, cmd)) { LOG_ERROR("enqueuing DTC reply entry: %s", strerror(errno)); exit(1); } @@ -1260,11 +1254,8 @@ static int rlink_scan(struct jtag_command *cmd, enum scan_type type, DTC_CMD_SHIFT_TMS_TDI_BIT_PAIR(1, (*tdi_p & tdi_mask), 0); } else { - if (dtc_queue_enqueue_reply( - type, buffer, scan_size, tdi_bit_offset, - 1, - cmd - ) == NULL) { + if (!dtc_queue_enqueue_reply(type, buffer, scan_size, tdi_bit_offset, + 1, cmd)) { LOG_ERROR("enqueuing DTC reply entry: %s", strerror(errno)); exit(1); } diff --git a/src/jtag/drivers/vsllink.c b/src/jtag/drivers/vsllink.c index 6361ee0..d298a94 100644 --- a/src/jtag/drivers/vsllink.c +++ b/src/jtag/drivers/vsllink.c @@ -803,7 +803,7 @@ static int vsllink_check_usb_strings( if (retval < 0) return ERROR_FAIL; - if (strstr(desc_string, "Versaloon") == NULL) + if (!strstr(desc_string, "Versaloon")) return ERROR_FAIL; return ERROR_OK; |