openocd: remove NULL comparisons with checkpatch [1/2]
Patch generated automatically through the new checkpatch with flags "--types COMPARISON_TO_NULL --fix-inplace". This only fixes the comparisons if (symbol == NULL) if (symbol != NULL) The case of NULL on the left side of the comparison is not tested. Some automatic fix is incorrect and has been massaged by hands: - if (*psig == NULL) + if (*!psig) changed as + if (!*psig) Change-Id: If4a1e2b4e547e223532e8e3d9da89bf9cb382ce6 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6351 Tested-by: jenkins
This commit is contained in:
@@ -209,7 +209,7 @@ static int at91rm9200_init(void)
|
||||
|
||||
cur_device = devices;
|
||||
|
||||
if (at91rm9200_device == NULL || at91rm9200_device[0] == 0) {
|
||||
if (!at91rm9200_device || at91rm9200_device[0] == 0) {
|
||||
at91rm9200_device = "rea_ecr";
|
||||
LOG_WARNING("No at91rm9200 device specified, using default 'rea_ecr'");
|
||||
}
|
||||
|
||||
@@ -1513,7 +1513,7 @@ static void cmsis_dap_add_jtag_sequence(int s_len, const uint8_t *sequence, int
|
||||
s_offset + offset,
|
||||
tms,
|
||||
tdo_buffer,
|
||||
tdo_buffer == NULL ? 0 : (tdo_buffer_offset + offset)
|
||||
!tdo_buffer ? 0 : (tdo_buffer_offset + offset)
|
||||
);
|
||||
}
|
||||
LOG_DEBUG_IO("END JTAG SEQ SPLIT");
|
||||
@@ -1530,7 +1530,7 @@ static void cmsis_dap_add_jtag_sequence(int s_len, const uint8_t *sequence, int
|
||||
/* control byte */
|
||||
queued_seq_buf[queued_seq_buf_end] =
|
||||
(tms ? DAP_JTAG_SEQ_TMS : 0) |
|
||||
(tdo_buffer != NULL ? DAP_JTAG_SEQ_TDO : 0) |
|
||||
(tdo_buffer ? DAP_JTAG_SEQ_TDO : 0) |
|
||||
(s_len == 64 ? 0 : s_len);
|
||||
|
||||
if (sequence)
|
||||
|
||||
@@ -82,7 +82,7 @@ int interface_jtag_add_ir_scan(struct jtag_tap *active,
|
||||
|
||||
/* loop over all enabled TAPs */
|
||||
|
||||
for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) {
|
||||
for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap; tap = jtag_tap_next_enabled(tap)) {
|
||||
/* search the input field list for fields for the current TAP */
|
||||
|
||||
if (tap == active) {
|
||||
@@ -122,7 +122,7 @@ int interface_jtag_add_dr_scan(struct jtag_tap *active, int in_num_fields,
|
||||
|
||||
size_t bypass_devices = 0;
|
||||
|
||||
for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) {
|
||||
for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap; tap = jtag_tap_next_enabled(tap)) {
|
||||
if (tap->bypass)
|
||||
bypass_devices++;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ int interface_jtag_add_dr_scan(struct jtag_tap *active, int in_num_fields,
|
||||
|
||||
/* loop over all enabled TAPs */
|
||||
|
||||
for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) {
|
||||
for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap; tap = jtag_tap_next_enabled(tap)) {
|
||||
/* if TAP is not bypassed insert matching input fields */
|
||||
|
||||
if (!tap->bypass) {
|
||||
@@ -369,7 +369,7 @@ int interface_jtag_execute_queue(void)
|
||||
int retval = default_interface_jtag_execute_queue();
|
||||
if (retval == ERROR_OK) {
|
||||
struct jtag_callback_entry *entry;
|
||||
for (entry = jtag_callback_queue_head; entry != NULL; entry = entry->next) {
|
||||
for (entry = jtag_callback_queue_head; entry; entry = entry->next) {
|
||||
retval = entry->callback(entry->data0, entry->data1, entry->data2, entry->data3);
|
||||
if (retval != ERROR_OK)
|
||||
break;
|
||||
|
||||
@@ -150,11 +150,11 @@ static struct signal *create_signal(const char *name)
|
||||
psig = &(*psig)->next;
|
||||
|
||||
*psig = calloc(1, sizeof(**psig));
|
||||
if (*psig == NULL)
|
||||
if (!*psig)
|
||||
return NULL;
|
||||
|
||||
(*psig)->name = strdup(name);
|
||||
if ((*psig)->name == NULL) {
|
||||
if (!(*psig)->name) {
|
||||
free(*psig);
|
||||
*psig = NULL;
|
||||
}
|
||||
@@ -1068,7 +1068,7 @@ static int ftdi_swd_init(void)
|
||||
swd_cmd_queue_alloced = 10;
|
||||
swd_cmd_queue = malloc(swd_cmd_queue_alloced * sizeof(*swd_cmd_queue));
|
||||
|
||||
return swd_cmd_queue != NULL ? ERROR_OK : ERROR_FAIL;
|
||||
return swd_cmd_queue ? ERROR_OK : ERROR_FAIL;
|
||||
}
|
||||
|
||||
static void ftdi_swd_swdio_en(bool enable)
|
||||
@@ -1143,7 +1143,7 @@ static int ftdi_swd_run_queue(void)
|
||||
goto skip;
|
||||
}
|
||||
|
||||
if (swd_cmd_queue[i].dst != NULL)
|
||||
if (swd_cmd_queue[i].dst)
|
||||
*swd_cmd_queue[i].dst = data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ static int jtag_dpi_execute_queue(void)
|
||||
struct jtag_command *cmd;
|
||||
int ret = ERROR_OK;
|
||||
|
||||
for (cmd = jtag_command_queue; ret == ERROR_OK && cmd != NULL;
|
||||
for (cmd = jtag_command_queue; ret == ERROR_OK && cmd;
|
||||
cmd = cmd->next) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_RUNTEST:
|
||||
|
||||
@@ -496,7 +496,7 @@ static int jtag_vpi_execute_queue(void)
|
||||
struct jtag_command *cmd;
|
||||
int retval = ERROR_OK;
|
||||
|
||||
for (cmd = jtag_command_queue; retval == ERROR_OK && cmd != NULL;
|
||||
for (cmd = jtag_command_queue; retval == ERROR_OK && cmd;
|
||||
cmd = cmd->next) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_RESET:
|
||||
|
||||
@@ -189,7 +189,7 @@ int jtag_libusb_open(const uint16_t vids[], const uint16_t pids[],
|
||||
}
|
||||
|
||||
/* Device must be open to use libusb_get_string_descriptor_ascii. */
|
||||
if (serial != NULL &&
|
||||
if (serial &&
|
||||
!jtag_libusb_match_serial(libusb_handle, &dev_desc, serial, adapter_get_alternate_serial)) {
|
||||
serial_mismatch = true;
|
||||
libusb_close(libusb_handle);
|
||||
@@ -285,7 +285,7 @@ int jtag_libusb_set_configuration(struct libusb_device_handle *devh,
|
||||
return retval;
|
||||
|
||||
retval = libusb_get_config_descriptor(udev, configuration, &config);
|
||||
if (retval != 0 || config == NULL)
|
||||
if (retval != 0 || !config)
|
||||
return retval;
|
||||
|
||||
/* Only change the configuration if it is not already set to the
|
||||
|
||||
@@ -250,7 +250,7 @@ static int remote_bitbang_init_tcp(void)
|
||||
If socket(2) (or connect(2)) fails, we (close the socket
|
||||
and) try the next address. */
|
||||
|
||||
for (rp = result; rp != NULL ; rp = rp->ai_next) {
|
||||
for (rp = result; rp ; rp = rp->ai_next) {
|
||||
fd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
|
||||
if (fd == -1)
|
||||
continue;
|
||||
|
||||
@@ -677,7 +677,7 @@ static int dtc_queue_run(void)
|
||||
|
||||
for (
|
||||
rq_p = dtc_queue.rq_head;
|
||||
rq_p != NULL;
|
||||
rq_p;
|
||||
rq_p = rq_next
|
||||
) {
|
||||
tdo_p = rq_p->scan.buffer + (rq_p->scan.offset / 8);
|
||||
|
||||
@@ -568,7 +568,7 @@ static int jtag_libusb_bulk_transfer_n(
|
||||
transfers[i].transfer_size = 0;
|
||||
transfers[i].transfer = libusb_alloc_transfer(0);
|
||||
|
||||
if (transfers[i].transfer == NULL) {
|
||||
if (!transfers[i].transfer) {
|
||||
for (size_t j = 0; j < i; ++j)
|
||||
libusb_free_transfer(transfers[j].transfer);
|
||||
|
||||
@@ -3084,7 +3084,7 @@ static int stlink_usb_usb_open(void *handle, struct hl_interface_param_s *param)
|
||||
h->cmdbuf = malloc(STLINK_SG_SIZE);
|
||||
h->databuf = malloc(STLINK_DATA_SIZE);
|
||||
|
||||
if (h->cmdbuf == NULL || h->databuf == NULL)
|
||||
if (!h->cmdbuf || !h->databuf)
|
||||
return ERROR_FAIL;
|
||||
|
||||
/*
|
||||
@@ -3198,7 +3198,7 @@ static int stlink_tcp_open(void *handle, struct hl_interface_param_s *param)
|
||||
h->tcp_backend_priv.send_buf = malloc(STLINK_TCP_SEND_BUFFER_SIZE);
|
||||
h->tcp_backend_priv.recv_buf = malloc(STLINK_TCP_RECV_BUFFER_SIZE);
|
||||
|
||||
if (h->tcp_backend_priv.send_buf == NULL || h->tcp_backend_priv.recv_buf == NULL)
|
||||
if (!h->tcp_backend_priv.send_buf || !h->tcp_backend_priv.recv_buf)
|
||||
return ERROR_FAIL;
|
||||
|
||||
h->cmdbuf = &h->tcp_backend_priv.send_buf[8];
|
||||
|
||||
@@ -788,7 +788,7 @@ static int ublast_execute_queue(void)
|
||||
ublast_initial_wipeout();
|
||||
}
|
||||
|
||||
for (cmd = jtag_command_queue; ret == ERROR_OK && cmd != NULL;
|
||||
for (cmd = jtag_command_queue; ret == ERROR_OK && cmd;
|
||||
cmd = cmd->next) {
|
||||
switch (cmd->type) {
|
||||
case JTAG_RESET:
|
||||
|
||||
@@ -171,10 +171,10 @@ RESULT usbtoxxx_execute_command(void)
|
||||
}
|
||||
|
||||
/* get result data */
|
||||
if (versaloon_pending[i].pos != NULL) {
|
||||
if (versaloon_pending[i].pos) {
|
||||
uint8_t processed = 0;
|
||||
|
||||
if (versaloon_pending[i].callback != NULL) {
|
||||
if (versaloon_pending[i].callback) {
|
||||
versaloon_pending[i].callback(&versaloon_pending[i],
|
||||
versaloon_buf + usbtoxxx_buffer_index, &processed);
|
||||
}
|
||||
@@ -197,10 +197,10 @@ RESULT usbtoxxx_execute_command(void)
|
||||
versaloon_pending[i].pos = NULL;
|
||||
}
|
||||
} else if ((versaloon_pending[i].want_data_size > 0)
|
||||
&& (versaloon_pending[i].data_buffer != NULL)) {
|
||||
&& (versaloon_pending[i].data_buffer)) {
|
||||
uint8_t processed = 0;
|
||||
|
||||
if (versaloon_pending[i].callback != NULL) {
|
||||
if (versaloon_pending[i].callback) {
|
||||
versaloon_pending[i].callback(&versaloon_pending[i],
|
||||
versaloon_buf + usbtoxxx_buffer_index, &processed);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user