aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/flash/nand/core.c8
-rw-r--r--src/flash/nor/at91sam3.c6
-rw-r--r--src/flash/nor/at91sam4.c6
-rw-r--r--src/flash/nor/at91sam7.c2
-rw-r--r--src/flash/nor/at91samd.c2
-rw-r--r--src/flash/nor/core.c4
-rw-r--r--src/flash/nor/jtagspi.c2
-rw-r--r--src/flash/nor/pic32mx.c6
-rw-r--r--src/flash/nor/tcl.c4
-rw-r--r--src/flash/nor/virtual.c2
-rw-r--r--src/flash/nor/xcf.c2
-rw-r--r--src/helper/command.c6
-rw-r--r--src/helper/log.c4
-rw-r--r--src/helper/replacements.c2
-rw-r--r--src/jtag/core.c4
-rw-r--r--src/jtag/drivers/at91rm9200.c2
-rw-r--r--src/jtag/drivers/cmsis_dap.c4
-rw-r--r--src/jtag/drivers/driver.c8
-rw-r--r--src/jtag/drivers/ftdi.c8
-rw-r--r--src/jtag/drivers/jtag_dpi.c2
-rw-r--r--src/jtag/drivers/jtag_vpi.c2
-rw-r--r--src/jtag/drivers/libusb_helper.c4
-rw-r--r--src/jtag/drivers/remote_bitbang.c2
-rw-r--r--src/jtag/drivers/rlink.c2
-rw-r--r--src/jtag/drivers/stlink_usb.c6
-rw-r--r--src/jtag/drivers/usb_blaster/usb_blaster.c2
-rw-r--r--src/jtag/drivers/versaloon/usbtoxxx/usbtoxxx.c8
-rw-r--r--src/jtag/hla/hla_interface.c4
-rw-r--r--src/jtag/tcl.c2
-rw-r--r--src/rtos/FreeRTOS.c2
-rw-r--r--src/rtos/ThreadX.c2
-rw-r--r--src/rtos/chibios.c4
-rw-r--r--src/rtos/eCos.c2
-rw-r--r--src/rtos/embKernel.c2
-rw-r--r--src/rtos/hwthread.c12
-rw-r--r--src/rtos/linux.c2
-rw-r--r--src/rtos/mqx.c2
-rw-r--r--src/rtos/nuttx.c2
-rw-r--r--src/rtos/riot.c8
-rw-r--r--src/rtos/rtos.c10
-rw-r--r--src/rtos/uCOS-III.c4
-rw-r--r--src/rtos/zephyr.c2
-rw-r--r--src/server/gdb_server.c32
-rw-r--r--src/server/tcl_server.c8
-rw-r--r--src/server/telnet_server.c4
-rw-r--r--src/svf/svf.c2
-rw-r--r--src/target/aarch64.c4
-rw-r--r--src/target/arc.c2
-rw-r--r--src/target/arm_adi_v5.c2
-rw-r--r--src/target/arm_adi_v5.h4
-rw-r--r--src/target/armv7a.c2
-rw-r--r--src/target/armv7m.c2
-rw-r--r--src/target/armv8.c8
-rw-r--r--src/target/armv8_cache.c2
-rw-r--r--src/target/cortex_a.c4
-rw-r--r--src/target/esirisc.c8
-rw-r--r--src/target/esirisc_jtag.c2
-rw-r--r--src/target/etm.c2
-rw-r--r--src/target/hla_target.c2
-rw-r--r--src/target/lakemont.c14
-rw-r--r--src/target/ls1_sap.c4
-rw-r--r--src/target/mem_ap.c4
-rw-r--r--src/target/mips_m4k.c2
-rw-r--r--src/target/nds32_aice.c26
-rw-r--r--src/target/riscv/riscv-013.c2
-rw-r--r--src/target/riscv/riscv.c4
-rw-r--r--src/target/semihosting_common.c2
-rw-r--r--src/target/target.c30
-rw-r--r--src/target/target_request.c4
-rw-r--r--src/target/x86_32_common.c8
-rw-r--r--src/transport/transport.c2
71 files changed, 181 insertions, 181 deletions
diff --git a/src/flash/nand/core.c b/src/flash/nand/core.c
index 8e2af23..d60e0d0 100644
--- a/src/flash/nand/core.c
+++ b/src/flash/nand/core.c
@@ -682,7 +682,7 @@ int nand_write_page(struct nand_device *nand, uint32_t page,
if (nand->blocks[block].is_erased == 1)
nand->blocks[block].is_erased = 0;
- if (nand->use_raw || nand->controller->write_page == NULL)
+ if (nand->use_raw || !nand->controller->write_page)
return nand_write_page_raw(nand, page, data, data_size, oob, oob_size);
else
return nand->controller->write_page(nand, page, data, data_size, oob, oob_size);
@@ -695,7 +695,7 @@ int nand_read_page(struct nand_device *nand, uint32_t page,
if (!nand->device)
return ERROR_NAND_DEVICE_NOT_PROBED;
- if (nand->use_raw || nand->controller->read_page == NULL)
+ if (nand->use_raw || !nand->controller->read_page)
return nand_read_page_raw(nand, page, data, data_size, oob, oob_size);
else
return nand->controller->read_page(nand, page, data, data_size, oob, oob_size);
@@ -769,7 +769,7 @@ int nand_read_data_page(struct nand_device *nand, uint8_t *data, uint32_t size)
{
int retval = ERROR_NAND_NO_BUFFER;
- if (nand->controller->read_block_data != NULL)
+ if (nand->controller->read_block_data)
retval = (nand->controller->read_block_data)(nand, data, size);
if (retval == ERROR_NAND_NO_BUFFER) {
@@ -809,7 +809,7 @@ int nand_write_data_page(struct nand_device *nand, uint8_t *data, uint32_t size)
{
int retval = ERROR_NAND_NO_BUFFER;
- if (nand->controller->write_block_data != NULL)
+ if (nand->controller->write_block_data)
retval = (nand->controller->write_block_data)(nand, data, size);
if (retval == ERROR_NAND_NO_BUFFER) {
diff --git a/src/flash/nor/at91sam3.c b/src/flash/nor/at91sam3.c
index 3f36af2..cec86fc 100644
--- a/src/flash/nor/at91sam3.c
+++ b/src/flash/nor/at91sam3.c
@@ -3545,7 +3545,7 @@ COMMAND_HANDLER(sam3_handle_info_command)
int r;
/* bank0 must exist before we can do anything */
- if (chip->details.bank[0].bank == NULL) {
+ if (!chip->details.bank[0].bank) {
x = 0;
need_define:
command_print(CMD,
@@ -3571,7 +3571,7 @@ need_define:
if (!(chip->details.bank[x].present))
continue;
- if (chip->details.bank[x].bank == NULL)
+ if (!chip->details.bank[x].bank)
goto need_define;
if (chip->details.bank[x].probed)
@@ -3606,7 +3606,7 @@ COMMAND_HANDLER(sam3_handle_gpnvm_command)
return ERROR_TARGET_NOT_HALTED;
}
- if (chip->details.bank[0].bank == NULL) {
+ if (!chip->details.bank[0].bank) {
command_print(CMD, "Bank0 must be defined first via: flash bank %s ...",
at91sam3_flash.name);
return ERROR_FAIL;
diff --git a/src/flash/nor/at91sam4.c b/src/flash/nor/at91sam4.c
index 23d1c5f..4ec2ee8 100644
--- a/src/flash/nor/at91sam4.c
+++ b/src/flash/nor/at91sam4.c
@@ -3092,7 +3092,7 @@ COMMAND_HANDLER(sam4_handle_info_command)
int r;
/* bank0 must exist before we can do anything */
- if (chip->details.bank[0].bank == NULL) {
+ if (!chip->details.bank[0].bank) {
x = 0;
need_define:
command_print(CMD,
@@ -3118,7 +3118,7 @@ need_define:
if (!(chip->details.bank[x].present))
continue;
- if (chip->details.bank[x].bank == NULL)
+ if (!chip->details.bank[x].bank)
goto need_define;
if (chip->details.bank[x].probed)
@@ -3153,7 +3153,7 @@ COMMAND_HANDLER(sam4_handle_gpnvm_command)
return ERROR_TARGET_NOT_HALTED;
}
- if (chip->details.bank[0].bank == NULL) {
+ if (!chip->details.bank[0].bank) {
command_print(CMD, "Bank0 must be defined first via: flash bank %s ...",
at91sam4_flash.name);
return ERROR_FAIL;
diff --git a/src/flash/nor/at91sam7.c b/src/flash/nor/at91sam7.c
index d3eadc7..f98d186 100644
--- a/src/flash/nor/at91sam7.c
+++ b/src/flash/nor/at91sam7.c
@@ -1040,7 +1040,7 @@ COMMAND_HANDLER(at91sam7_handle_gpnvm_command)
return ERROR_COMMAND_SYNTAX_ERROR;
bank = get_flash_bank_by_num_noprobe(0);
- if (bank == NULL)
+ if (!bank)
return ERROR_FLASH_BANK_INVALID;
if (strcmp(bank->driver->name, "at91sam7")) {
command_print(CMD, "not an at91sam7 flash bank '%s'", CMD_ARGV[0]);
diff --git a/src/flash/nor/at91samd.c b/src/flash/nor/at91samd.c
index ea85039..76c08d7 100644
--- a/src/flash/nor/at91samd.c
+++ b/src/flash/nor/at91samd.c
@@ -1064,7 +1064,7 @@ static COMMAND_HELPER(get_u64_from_hexarg, unsigned int num, uint64_t *value)
char *check = NULL;
*value = strtoull(&(CMD_ARGV[num][2]), &check, 16);
if ((value == 0 && errno == ERANGE) ||
- check == NULL || *check != 0) {
+ !check || *check != 0) {
command_print(CMD, "Invalid 64-bit hex value in argument %d.",
num + 1);
return ERROR_COMMAND_SYNTAX_ERROR;
diff --git a/src/flash/nor/core.c b/src/flash/nor/core.c
index 41d2d34..a2d7623 100644
--- a/src/flash/nor/core.c
+++ b/src/flash/nor/core.c
@@ -70,7 +70,7 @@ int flash_driver_protect(struct flash_bank *bank, int set, unsigned int first,
/* force "set" to 0/1 */
set = !!set;
- if (bank->driver->protect == NULL) {
+ if (!bank->driver->protect) {
LOG_ERROR("Flash protection is not supported.");
return ERROR_FLASH_OPER_UNSUPPORTED;
}
@@ -491,7 +491,7 @@ static int flash_iterate_address_range_inner(struct target *target,
return ERROR_FLASH_DST_BREAKS_ALIGNMENT;
}
- if (c->prot_blocks == NULL || c->num_prot_blocks == 0) {
+ if (!c->prot_blocks || c->num_prot_blocks == 0) {
/* flash driver does not define protect blocks, use sectors instead */
iterate_protect_blocks = false;
}
diff --git a/src/flash/nor/jtagspi.c b/src/flash/nor/jtagspi.c
index fade970..dc49fda 100644
--- a/src/flash/nor/jtagspi.c
+++ b/src/flash/nor/jtagspi.c
@@ -172,7 +172,7 @@ static int jtagspi_probe(struct flash_bank *bank)
free(bank->sectors);
info->probed = false;
- if (bank->target->tap == NULL) {
+ if (!bank->target->tap) {
LOG_ERROR("Target has no JTAG tap");
return ERROR_FAIL;
}
diff --git a/src/flash/nor/pic32mx.c b/src/flash/nor/pic32mx.c
index 5e6c99f..a1f2cdf 100644
--- a/src/flash/nor/pic32mx.c
+++ b/src/flash/nor/pic32mx.c
@@ -714,7 +714,7 @@ static int pic32mx_probe(struct flash_bank *bank)
}
/* Check for PIC32mx1xx/2xx */
- for (i = 0; pic32mx_devs[i].name != NULL; i++) {
+ for (i = 0; pic32mx_devs[i].name; i++) {
if (pic32mx_devs[i].devid == (device_id & 0x0fffffff)) {
if ((pic32mx_devs[i].name[0] == '1') || (pic32mx_devs[i].name[0] == '2'))
pic32mx_info->dev_type = (pic32mx_devs[i].name[1] == '7') ? MX_17X_27X : MX_1XX_2XX;
@@ -819,14 +819,14 @@ static int pic32mx_info(struct flash_bank *bank, struct command_invocation *cmd)
}
int i;
- for (i = 0; pic32mx_devs[i].name != NULL; i++) {
+ for (i = 0; pic32mx_devs[i].name; i++) {
if (pic32mx_devs[i].devid == (device_id & 0x0fffffff)) {
command_print_sameline(cmd, "PIC32MX%s", pic32mx_devs[i].name);
break;
}
}
- if (pic32mx_devs[i].name == NULL)
+ if (!pic32mx_devs[i].name)
command_print_sameline(cmd, "Unknown");
command_print_sameline(cmd, " Ver: 0x%02x",
diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c
index d746650..b078e90 100644
--- a/src/flash/nor/tcl.c
+++ b/src/flash/nor/tcl.c
@@ -99,7 +99,7 @@ COMMAND_HANDLER(handle_flash_info_command)
/* If the driver does not implement protection, we show the default
* state of is_protected array - usually protection state unknown */
- if (p->driver->protect_check == NULL) {
+ if (!p->driver->protect_check) {
retval = ERROR_FLASH_OPER_UNSUPPORTED;
} else {
/* We must query the hardware to avoid printing stale information! */
@@ -148,7 +148,7 @@ COMMAND_HANDLER(handle_flash_info_command)
protect_state);
}
- if (p->driver->info != NULL) {
+ if (p->driver->info) {
/* Let the flash driver print extra custom info */
retval = p->driver->info(p, CMD);
command_print_sameline(CMD, "\n");
diff --git a/src/flash/nor/virtual.c b/src/flash/nor/virtual.c
index deab3c0..01a9247 100644
--- a/src/flash/nor/virtual.c
+++ b/src/flash/nor/virtual.c
@@ -93,7 +93,7 @@ static int virtual_protect_check(struct flash_bank *bank)
if (!master_bank)
return ERROR_FLASH_OPERATION_FAILED;
- if (master_bank->driver->protect_check == NULL)
+ if (!master_bank->driver->protect_check)
return ERROR_FLASH_OPER_UNSUPPORTED;
/* call master handler */
diff --git a/src/flash/nor/xcf.c b/src/flash/nor/xcf.c
index fd31c9d..c6de1ac 100644
--- a/src/flash/nor/xcf.c
+++ b/src/flash/nor/xcf.c
@@ -602,7 +602,7 @@ static int xcf_probe(struct flash_bank *bank)
free(bank->sectors);
priv->probed = false;
- if (bank->target->tap == NULL) {
+ if (!bank->target->tap) {
LOG_ERROR("Target has no JTAG tap");
return ERROR_FAIL;
}
diff --git a/src/helper/command.c b/src/helper/command.c
index b3b53ae..681e870 100644
--- a/src/helper/command.c
+++ b/src/helper/command.c
@@ -221,7 +221,7 @@ static char **script_command_args_alloc(
int len;
const char *w = Jim_GetString(argv[i], &len);
words[i] = strdup(w);
- if (words[i] == NULL) {
+ if (!words[i]) {
script_command_args_free(words, i);
return NULL;
}
@@ -501,7 +501,7 @@ void command_print_sameline(struct command_invocation *cmd, const char *format,
va_start(ap, format);
string = alloc_vprintf(format, ap);
- if (string != NULL && cmd) {
+ if (string && cmd) {
/* we want this collected in the log + we also want to pick it up as a tcl return
* value.
*
@@ -524,7 +524,7 @@ void command_print(struct command_invocation *cmd, const char *format, ...)
va_start(ap, format);
string = alloc_vprintf(format, ap);
- if (string != NULL && cmd) {
+ if (string && cmd) {
strcat(string, "\n"); /* alloc_vprintf guaranteed the buffer to be at least one
*char longer */
/* we want this collected in the log + we also want to pick it up as a tcl return
diff --git a/src/helper/log.c b/src/helper/log.c
index a1b46ef..caa0a66 100644
--- a/src/helper/log.c
+++ b/src/helper/log.c
@@ -230,7 +230,7 @@ COMMAND_HANDLER(handle_debug_level_command)
COMMAND_HANDLER(handle_log_output_command)
{
if (CMD_ARGC == 0 || (CMD_ARGC == 1 && strcmp(CMD_ARGV[0], "default") == 0)) {
- if (log_output != stderr && log_output != NULL) {
+ if (log_output != stderr && log_output) {
/* Close previous log file, if it was open and wasn't stderr. */
fclose(log_output);
}
@@ -244,7 +244,7 @@ COMMAND_HANDLER(handle_log_output_command)
LOG_ERROR("failed to open output log '%s'", CMD_ARGV[0]);
return ERROR_FAIL;
}
- if (log_output != stderr && log_output != NULL) {
+ if (log_output != stderr && log_output) {
/* Close previous log file, if it was open and wasn't stderr. */
fclose(log_output);
}
diff --git a/src/helper/replacements.c b/src/helper/replacements.c
index 68032b7..86ddd80 100644
--- a/src/helper/replacements.c
+++ b/src/helper/replacements.c
@@ -145,7 +145,7 @@ int win_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct time
struct timeval tvslice;
int retcode;
-#define SAFE_FD_ISSET(fd, set) (set != NULL && FD_ISSET(fd, set))
+#define SAFE_FD_ISSET(fd, set) (set && FD_ISSET(fd, set))
/* calculate how long we need to wait in milliseconds */
if (!tv)
diff --git a/src/jtag/core.c b/src/jtag/core.c
index 3d63fdd..51c1228 100644
--- a/src/jtag/core.c
+++ b/src/jtag/core.c
@@ -218,7 +218,7 @@ static void jtag_tap_add(struct jtag_tap *t)
unsigned jtag_num_taps = 0;
struct jtag_tap **tap = &__jtag_all_taps;
- while (*tap != NULL) {
+ while (*tap) {
jtag_num_taps++;
tap = &(*tap)->next_tap;
}
@@ -429,7 +429,7 @@ static void jtag_add_scan_check(struct jtag_tap *active, void (*jtag_add_scan)(
jtag_add_scan(active, in_num_fields, in_fields, state);
for (int i = 0; i < in_num_fields; i++) {
- if ((in_fields[i].check_value != NULL) && (in_fields[i].in_value != NULL)) {
+ if ((in_fields[i].check_value) && (in_fields[i].in_value)) {
jtag_add_callback4(jtag_check_value_mask_callback,
(jtag_callback_data_t)in_fields[i].in_value,
(jtag_callback_data_t)in_fields[i].check_value,
diff --git a/src/jtag/drivers/at91rm9200.c b/src/jtag/drivers/at91rm9200.c
index bccb9bb..7bb5d85 100644
--- a/src/jtag/drivers/at91rm9200.c
+++ b/src/jtag/drivers/at91rm9200.c
@@ -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'");
}
diff --git a/src/jtag/drivers/cmsis_dap.c b/src/jtag/drivers/cmsis_dap.c
index 68fd470..be8881d 100644
--- a/src/jtag/drivers/cmsis_dap.c
+++ b/src/jtag/drivers/cmsis_dap.c
@@ -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)
diff --git a/src/jtag/drivers/driver.c b/src/jtag/drivers/driver.c
index e73876c..dbe3b08 100644
--- a/src/jtag/drivers/driver.c
+++ b/src/jtag/drivers/driver.c
@@ -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;
diff --git a/src/jtag/drivers/ftdi.c b/src/jtag/drivers/ftdi.c
index f17cd9f..82298c2 100644
--- a/src/jtag/drivers/ftdi.c
+++ b/src/jtag/drivers/ftdi.c
@@ -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;
}
}
diff --git a/src/jtag/drivers/jtag_dpi.c b/src/jtag/drivers/jtag_dpi.c
index ceb6628..73746d6 100644
--- a/src/jtag/drivers/jtag_dpi.c
+++ b/src/jtag/drivers/jtag_dpi.c
@@ -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:
diff --git a/src/jtag/drivers/jtag_vpi.c b/src/jtag/drivers/jtag_vpi.c
index aeed6a5..a5b51ae 100644
--- a/src/jtag/drivers/jtag_vpi.c
+++ b/src/jtag/drivers/jtag_vpi.c
@@ -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:
diff --git a/src/jtag/drivers/libusb_helper.c b/src/jtag/drivers/libusb_helper.c
index 33f680c..f285bdc 100644
--- a/src/jtag/drivers/libusb_helper.c
+++ b/src/jtag/drivers/libusb_helper.c
@@ -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
diff --git a/src/jtag/drivers/remote_bitbang.c b/src/jtag/drivers/remote_bitbang.c
index ac1040e..6d1f48b 100644
--- a/src/jtag/drivers/remote_bitbang.c
+++ b/src/jtag/drivers/remote_bitbang.c
@@ -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;
diff --git a/src/jtag/drivers/rlink.c b/src/jtag/drivers/rlink.c
index 7a41a69..8b6aa3e 100644
--- a/src/jtag/drivers/rlink.c
+++ b/src/jtag/drivers/rlink.c
@@ -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);
diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c
index 811ad53..0e86dcd 100644
--- a/src/jtag/drivers/stlink_usb.c
+++ b/src/jtag/drivers/stlink_usb.c
@@ -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];
diff --git a/src/jtag/drivers/usb_blaster/usb_blaster.c b/src/jtag/drivers/usb_blaster/usb_blaster.c
index aa7c240..8519d19 100644
--- a/src/jtag/drivers/usb_blaster/usb_blaster.c
+++ b/src/jtag/drivers/usb_blaster/usb_blaster.c
@@ -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:
diff --git a/src/jtag/drivers/versaloon/usbtoxxx/usbtoxxx.c b/src/jtag/drivers/versaloon/usbtoxxx/usbtoxxx.c
index ee3b724..fecd32c 100644
--- a/src/jtag/drivers/versaloon/usbtoxxx/usbtoxxx.c
+++ b/src/jtag/drivers/versaloon/usbtoxxx/usbtoxxx.c
@@ -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);
}
diff --git a/src/jtag/hla/hla_interface.c b/src/jtag/hla/hla_interface.c
index 0aaf22f..b16a930 100644
--- a/src/jtag/hla/hla_interface.c
+++ b/src/jtag/hla/hla_interface.c
@@ -147,7 +147,7 @@ int hl_interface_init_reset(void)
static int hl_interface_khz(int khz, int *jtag_speed)
{
- if (hl_if.layout->api->speed == NULL)
+ if (!hl_if.layout->api->speed)
return ERROR_OK;
*jtag_speed = hl_if.layout->api->speed(hl_if.handle, khz, true);
@@ -162,7 +162,7 @@ static int hl_interface_speed_div(int speed, int *khz)
static int hl_interface_speed(int speed)
{
- if (hl_if.layout->api->speed == NULL)
+ if (!hl_if.layout->api->speed)
return ERROR_OK;
if (!hl_if.handle) {
diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c
index af2f149..6d3fee4 100644
--- a/src/jtag/tcl.c
+++ b/src/jtag/tcl.c
@@ -640,7 +640,7 @@ static void jtag_tap_handle_event(struct jtag_tap *tap, enum jtag_event e)
struct jtag_tap_event_action *jteap;
int retval;
- for (jteap = tap->event_action; jteap != NULL; jteap = jteap->next) {
+ for (jteap = tap->event_action; jteap; jteap = jteap->next) {
if (jteap->event != e)
continue;
diff --git a/src/rtos/FreeRTOS.c b/src/rtos/FreeRTOS.c
index 87b1681..f7ce8cd 100644
--- a/src/rtos/FreeRTOS.c
+++ b/src/rtos/FreeRTOS.c
@@ -531,7 +531,7 @@ static int freertos_get_thread_ascii_info(struct rtos *rtos, threadid_t thread_i
static bool freertos_detect_rtos(struct target *target)
{
- if ((target->rtos->symbols != NULL) &&
+ if ((target->rtos->symbols) &&
(target->rtos->symbols[FREERTOS_VAL_PX_READY_TASKS_LISTS].address != 0)) {
/* looks like FreeRTOS */
return true;
diff --git a/src/rtos/ThreadX.c b/src/rtos/ThreadX.c
index c7effe7..788edc0 100644
--- a/src/rtos/ThreadX.c
+++ b/src/rtos/ThreadX.c
@@ -491,7 +491,7 @@ static int threadx_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_li
static bool threadx_detect_rtos(struct target *target)
{
- if ((target->rtos->symbols != NULL) &&
+ if ((target->rtos->symbols) &&
(target->rtos->symbols[THREADX_VAL_TX_THREAD_CREATED_PTR].address != 0)) {
/* looks like ThreadX */
return true;
diff --git a/src/rtos/chibios.c b/src/rtos/chibios.c
index 6539a78..ef1f34d 100644
--- a/src/rtos/chibios.c
+++ b/src/rtos/chibios.c
@@ -500,7 +500,7 @@ static int chibios_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_li
{
*symbol_list = malloc(sizeof(chibios_symbol_list));
- if (*symbol_list == NULL)
+ if (!*symbol_list)
return ERROR_FAIL;
memcpy(*symbol_list, chibios_symbol_list, sizeof(chibios_symbol_list));
@@ -509,7 +509,7 @@ static int chibios_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_li
static bool chibios_detect_rtos(struct target *target)
{
- if ((target->rtos->symbols != NULL) &&
+ if ((target->rtos->symbols) &&
((target->rtos->symbols[CHIBIOS_VAL_RLIST].address != 0) ||
(target->rtos->symbols[CHIBIOS_VAL_CH].address != 0))) {
diff --git a/src/rtos/eCos.c b/src/rtos/eCos.c
index c6b2628..a81d7b9 100644
--- a/src/rtos/eCos.c
+++ b/src/rtos/eCos.c
@@ -363,7 +363,7 @@ static int ecos_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[
static bool ecos_detect_rtos(struct target *target)
{
- if ((target->rtos->symbols != NULL) &&
+ if ((target->rtos->symbols) &&
(target->rtos->symbols[ECOS_VAL_THREAD_LIST].address != 0)) {
/* looks like eCos */
return true;
diff --git a/src/rtos/embKernel.c b/src/rtos/embKernel.c
index 1987fd5..85c8d19 100644
--- a/src/rtos/embKernel.c
+++ b/src/rtos/embKernel.c
@@ -110,7 +110,7 @@ static const struct embkernel_params embkernel_params_list[] = {
static bool embkernel_detect_rtos(struct target *target)
{
- if (target->rtos->symbols != NULL) {
+ if (target->rtos->symbols) {
if (target->rtos->symbols[SYMBOL_ID_S_CURRENT_TASK].address != 0)
return true;
}
diff --git a/src/rtos/hwthread.c b/src/rtos/hwthread.c
index 5732ac2..3702b0b 100644
--- a/src/rtos/hwthread.c
+++ b/src/rtos/hwthread.c
@@ -107,7 +107,7 @@ static int hwthread_update_threads(struct rtos *rtos)
/* determine the number of "threads" */
if (target->smp) {
- for (head = target->head; head != NULL; head = head->next) {
+ for (head = target->head; head; head = head->next) {
struct target *curr = head->target;
if (!target_was_examined(curr))
@@ -123,7 +123,7 @@ static int hwthread_update_threads(struct rtos *rtos)
if (target->smp) {
/* loop over all threads */
- for (head = target->head; head != NULL; head = head->next) {
+ for (head = target->head; head; head = head->next) {
struct target *curr = head->target;
if (!target_was_examined(curr))
@@ -218,7 +218,7 @@ static struct target *hwthread_find_thread(struct target *target, int64_t thread
if (!target)
return NULL;
if (target->smp) {
- for (struct target_list *head = target->head; head != NULL; head = head->next) {
+ for (struct target_list *head = target->head; head; head = head->next) {
if (thread_id == threadid_from_target(head->target))
return head->target;
}
@@ -252,20 +252,20 @@ static int hwthread_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
int j = 0;
for (int i = 0; i < reg_list_size; i++) {
- if (reg_list[i] == NULL || reg_list[i]->exist == false || reg_list[i]->hidden)
+ if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden)
continue;
j++;
}
*rtos_reg_list_size = j;
*rtos_reg_list = calloc(*rtos_reg_list_size, sizeof(struct rtos_reg));
- if (*rtos_reg_list == NULL) {
+ if (!*rtos_reg_list) {
free(reg_list);
return ERROR_FAIL;
}
j = 0;
for (int i = 0; i < reg_list_size; i++) {
- if (reg_list[i] == NULL || reg_list[i]->exist == false || reg_list[i]->hidden)
+ if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden)
continue;
(*rtos_reg_list)[j].number = (*reg_list)[i].number;
(*rtos_reg_list)[j].size = (*reg_list)[i].size;
diff --git a/src/rtos/linux.c b/src/rtos/linux.c
index b9749b5..11a55c4 100644
--- a/src/rtos/linux.c
+++ b/src/rtos/linux.c
@@ -639,7 +639,7 @@ static struct threads *liste_add_task(struct threads *task_list, struct threads
{
t->next = NULL;
- if (*last == NULL)
+ if (!*last)
if (!task_list) {
task_list = t;
return task_list;
diff --git a/src/rtos/mqx.c b/src/rtos/mqx.c
index f6be35b..710436b 100644
--- a/src/rtos/mqx.c
+++ b/src/rtos/mqx.c
@@ -243,7 +243,7 @@ static bool mqx_detect_rtos(
)
{
if (
- (target->rtos->symbols != NULL) &&
+ (target->rtos->symbols) &&
(target->rtos->symbols[MQX_VAL_MQX_KERNEL_DATA].address != 0)
) {
return true;
diff --git a/src/rtos/nuttx.c b/src/rtos/nuttx.c
index 00fec7f..cc352d1 100644
--- a/src/rtos/nuttx.c
+++ b/src/rtos/nuttx.c
@@ -233,7 +233,7 @@ retok:
static bool nuttx_detect_rtos(struct target *target)
{
- if ((target->rtos->symbols != NULL) &&
+ if ((target->rtos->symbols) &&
(target->rtos->symbols[0].address != 0) &&
(target->rtos->symbols[1].address != 0)) {
return true;
diff --git a/src/rtos/riot.c b/src/rtos/riot.c
index 2316f17..6652db6 100644
--- a/src/rtos/riot.c
+++ b/src/rtos/riot.c
@@ -255,7 +255,7 @@ static int riot_update_threads(struct rtos *rtos)
strdup(riot_thread_states[k].desc);
}
- if (rtos->thread_details[tasks_found].extra_info_str == NULL) {
+ if (!rtos->thread_details[tasks_found].extra_info_str) {
LOG_ERROR("RIOT: out of memory");
retval = ERROR_FAIL;
goto error;
@@ -297,7 +297,7 @@ static int riot_update_threads(struct rtos *rtos)
strdup("Enable DEVELHELP to see task names");
}
- if (rtos->thread_details[tasks_found].thread_name_str == NULL) {
+ if (!rtos->thread_details[tasks_found].thread_name_str) {
LOG_ERROR("RIOT: out of memory");
retval = ERROR_FAIL;
goto error;
@@ -364,7 +364,7 @@ static int riot_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[
{
*symbol_list = calloc(ARRAY_SIZE(riot_symbol_list), sizeof(struct symbol_table_elem));
- if (*symbol_list == NULL) {
+ if (!*symbol_list) {
LOG_ERROR("RIOT: out of memory");
return ERROR_FAIL;
}
@@ -387,7 +387,7 @@ static int riot_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[
static bool riot_detect_rtos(struct target *target)
{
- if ((target->rtos->symbols != NULL) &&
+ if ((target->rtos->symbols) &&
(target->rtos->symbols[RIOT_THREADS_BASE].address != 0)) {
/* looks like RIOT */
return true;
diff --git a/src/rtos/rtos.c b/src/rtos/rtos.c
index 54e9926..2b62154 100644
--- a/src/rtos/rtos.c
+++ b/src/rtos/rtos.c
@@ -306,13 +306,13 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
struct target *target = get_target_from_connection(connection);
if (strncmp(packet, "qThreadExtraInfo,", 17) == 0) {
- if ((target->rtos) && (target->rtos->thread_details != NULL) &&
+ if ((target->rtos) && (target->rtos->thread_details) &&
(target->rtos->thread_count != 0)) {
threadid_t threadid = 0;
int found = -1;
sscanf(packet, "qThreadExtraInfo,%" SCNx64, &threadid);
- if ((target->rtos) && (target->rtos->thread_details != NULL)) {
+ if ((target->rtos) && (target->rtos->thread_details)) {
int thread_num;
for (thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) {
if (target->rtos->thread_details[thread_num].threadid == threadid) {
@@ -416,7 +416,7 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
threadid_t threadid;
int found = -1;
sscanf(packet, "T%" SCNx64, &threadid);
- if ((target->rtos) && (target->rtos->thread_details != NULL)) {
+ if ((target->rtos) && (target->rtos->thread_details)) {
int thread_num;
for (thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) {
if (target->rtos->thread_details[thread_num].threadid == threadid) {
@@ -564,7 +564,7 @@ int rtos_set_reg(struct connection *connection, int reg_num,
struct target *target = get_target_from_connection(connection);
int64_t current_threadid = target->rtos->current_threadid;
if ((target->rtos) &&
- (target->rtos->type->set_reg != NULL) &&
+ (target->rtos->type->set_reg) &&
(current_threadid != -1) &&
(current_threadid != 0)) {
return target->rtos->type->set_reg(target->rtos, reg_num, reg_value);
@@ -657,7 +657,7 @@ static int rtos_try_next(struct target *target)
int rtos_update_threads(struct target *target)
{
- if ((target->rtos) && (target->rtos->type != NULL))
+ if ((target->rtos) && (target->rtos->type))
target->rtos->type->update_threads(target->rtos);
return ERROR_OK;
}
diff --git a/src/rtos/uCOS-III.c b/src/rtos/uCOS-III.c
index 4cdf72d..385c8d8 100644
--- a/src/rtos/uCOS-III.c
+++ b/src/rtos/uCOS-III.c
@@ -257,7 +257,7 @@ static int ucos_iii_update_thread_offsets(struct rtos *rtos)
static bool ucos_iii_detect_rtos(struct target *target)
{
- return target->rtos->symbols != NULL &&
+ return target->rtos->symbols &&
target->rtos->symbols[UCOS_III_VAL_OS_RUNNING].address != 0;
}
@@ -511,7 +511,7 @@ static int ucos_iii_get_thread_reg_list(struct rtos *rtos, threadid_t threadid,
static int ucos_iii_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[])
{
*symbol_list = calloc(ARRAY_SIZE(ucos_iii_symbol_list), sizeof(struct symbol_table_elem));
- if (*symbol_list == NULL) {
+ if (!*symbol_list) {
LOG_ERROR("uCOS-III: out of memory");
return ERROR_FAIL;
}
diff --git a/src/rtos/zephyr.c b/src/rtos/zephyr.c
index ef5ff58..fc5e037 100644
--- a/src/rtos/zephyr.c
+++ b/src/rtos/zephyr.c
@@ -385,7 +385,7 @@ static const struct symbol_table_elem zephyr_symbol_list[] = {
static bool zephyr_detect_rtos(struct target *target)
{
- if (target->rtos->symbols == NULL) {
+ if (!target->rtos->symbols) {
LOG_INFO("Zephyr: no symbols while detecting RTOS");
return false;
}
diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index bc3a675..3a39f8a 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -1043,7 +1043,7 @@ static int gdb_new_connection(struct connection *connection)
}
gdb_actual_connections++;
- log_printf_lf(all_targets->next != NULL ? LOG_LVL_INFO : LOG_LVL_DEBUG,
+ log_printf_lf(all_targets->next ? LOG_LVL_INFO : LOG_LVL_DEBUG,
__FILE__, __LINE__, __func__,
"New GDB Connection: %d, Target %s, state: %s",
gdb_actual_connections,
@@ -1221,7 +1221,7 @@ static int gdb_get_registers_packet(struct connection *connection,
return gdb_error(connection, retval);
for (i = 0; i < reg_list_size; i++) {
- if (reg_list[i] == NULL || reg_list[i]->exist == false || reg_list[i]->hidden)
+ if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden)
continue;
reg_packet_size += DIV_ROUND_UP(reg_list[i]->size, 8) * 2;
}
@@ -1235,7 +1235,7 @@ static int gdb_get_registers_packet(struct connection *connection,
reg_packet_p = reg_packet;
for (i = 0; i < reg_list_size; i++) {
- if (reg_list[i] == NULL || reg_list[i]->exist == false || reg_list[i]->hidden)
+ if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden)
continue;
if (!reg_list[i]->valid) {
retval = reg_list[i]->type->get(reg_list[i]);
@@ -1792,14 +1792,14 @@ static __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6))) void xml_printf(
int first = 1;
for (;; ) {
- if ((*xml == NULL) || (!first)) {
+ if ((!*xml) || (!first)) {
/* start by 0 to exercise all the code paths.
* Need minimum 2 bytes to fit 1 char and 0 terminator. */
*size = *size * 2 + 2;
char *t = *xml;
*xml = realloc(*xml, *size);
- if (*xml == NULL) {
+ if (!*xml) {
free(t);
*retval = ERROR_SERVER_REMOTE_CLOSED;
return;
@@ -1840,7 +1840,7 @@ static int decode_xfer_read(char const *buf, char **annex, int *ofs, unsigned in
/* Extract the annex if needed */
if (annex) {
*annex = strndup(buf, annex_end - buf);
- if (*annex == NULL)
+ if (!*annex)
return ERROR_FAIL;
}
@@ -2059,7 +2059,7 @@ static int lookup_add_arch_defined_types(char const **arch_defined_types_list[],
{
int tbl_sz = *num_arch_defined_types;
- if (type_id != NULL && (strcmp(type_id, ""))) {
+ if (type_id && (strcmp(type_id, ""))) {
for (int j = 0; j < (tbl_sz + 1); j++) {
if (!((*arch_defined_types_list)[j])) {
(*arch_defined_types_list)[tbl_sz++] = type_id;
@@ -2224,8 +2224,8 @@ static int get_reg_features_list(struct target *target, char const **feature_lis
if (reg_list[i]->exist == false || reg_list[i]->hidden)
continue;
- if (reg_list[i]->feature != NULL
- && reg_list[i]->feature->name != NULL
+ if (reg_list[i]->feature
+ && reg_list[i]->feature->name
&& (strcmp(reg_list[i]->feature->name, ""))) {
/* We found a feature, check if the feature is already in the
* table. If not, allocate a new entry for the table and
@@ -2322,7 +2322,7 @@ static int gdb_generate_target_description(struct target *target, char **tdesc_o
continue;
const char *type_str;
- if (reg_list[i]->reg_data_type != NULL) {
+ if (reg_list[i]->reg_data_type) {
if (reg_list[i]->reg_data_type->type == REG_TYPE_ARCH_DEFINED) {
/* generate <type... first, if there are architecture-defined types. */
if (lookup_add_arch_defined_types(&arch_defined_types,
@@ -2360,7 +2360,7 @@ static int gdb_generate_target_description(struct target *target, char **tdesc_o
xml_printf(&retval, &tdesc, &pos, &size,
" type=\"%s\"", type_str);
- if (reg_list[i]->group != NULL)
+ if (reg_list[i]->group)
xml_printf(&retval, &tdesc, &pos, &size,
" group=\"%s\"", reg_list[i]->group);
@@ -2420,7 +2420,7 @@ static int gdb_get_target_description_chunk(struct target *target, struct target
transfer_type = 'l';
*chunk = malloc(length + 2);
- if (*chunk == NULL) {
+ if (!*chunk) {
LOG_ERROR("Unable to allocate memory");
return ERROR_FAIL;
}
@@ -2543,7 +2543,7 @@ static int gdb_generate_thread_list(struct target *target, char **thread_list_ou
static int gdb_get_thread_list_chunk(struct target *target, char **thread_list,
char **chunk, int32_t offset, uint32_t length)
{
- if (*thread_list == NULL) {
+ if (!*thread_list) {
int retval = gdb_generate_thread_list(target, thread_list);
if (retval != ERROR_OK) {
LOG_ERROR("Unable to Generate Thread List");
@@ -2565,7 +2565,7 @@ static int gdb_get_thread_list_chunk(struct target *target, char **thread_list,
* of strlen(chunk) word access:
* Invalid read of size 4
* Address 0x4479934 is 44 bytes inside a block of size 45 alloc'd */
- if (*chunk == NULL) {
+ if (!*chunk) {
LOG_ERROR("Unable to allocate memory");
return ERROR_FAIL;
}
@@ -2770,7 +2770,7 @@ static bool gdb_handle_vcont_packet(struct connection *connection, const char *p
/* query for vCont supported */
if (parse[0] == '?') {
- if (target->type->step != NULL) {
+ if (target->type->step) {
/* gdb doesn't accept c without C and s without S */
gdb_put_packet(connection, "vCont;c;C;s;S", 13);
return true;
@@ -3007,7 +3007,7 @@ static bool gdb_handle_vrun_packet(struct connection *connection, const char *pa
char *cmdline = next_hex_encoded_field(&parse, ';');
char *arg;
- while (cmdline != NULL && (arg = next_hex_encoded_field(&parse, ';')) != NULL) {
+ while (cmdline && (arg = next_hex_encoded_field(&parse, ';')) != NULL) {
char *new_cmdline = alloc_printf("%s %s", cmdline, arg);
free(cmdline);
free(arg);
diff --git a/src/server/tcl_server.c b/src/server/tcl_server.c
index 92a8026..e088232 100644
--- a/src/server/tcl_server.c
+++ b/src/server/tcl_server.c
@@ -298,10 +298,10 @@ COMMAND_HANDLER(handle_tcl_notifications_command)
struct connection *connection = NULL;
struct tcl_connection *tclc = NULL;
- if (CMD_CTX->output_handler_priv != NULL)
+ if (CMD_CTX->output_handler_priv)
connection = CMD_CTX->output_handler_priv;
- if (connection != NULL && !strcmp(connection->service->name, "tcl")) {
+ if (connection && !strcmp(connection->service->name, "tcl")) {
tclc = connection->priv;
return CALL_COMMAND_HANDLER(handle_command_parse_bool, &tclc->tc_notify, "Target Notification output ");
} else {
@@ -315,10 +315,10 @@ COMMAND_HANDLER(handle_tcl_trace_command)
struct connection *connection = NULL;
struct tcl_connection *tclc = NULL;
- if (CMD_CTX->output_handler_priv != NULL)
+ if (CMD_CTX->output_handler_priv)
connection = CMD_CTX->output_handler_priv;
- if (connection != NULL && !strcmp(connection->service->name, "tcl")) {
+ if (connection && !strcmp(connection->service->name, "tcl")) {
tclc = connection->priv;
return CALL_COMMAND_HANDLER(handle_command_parse_bool, &tclc->tc_trace, "Target trace output ");
} else {
diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c
index b01046d..97af3d9 100644
--- a/src/server/telnet_server.c
+++ b/src/server/telnet_server.c
@@ -199,7 +199,7 @@ static void telnet_save_history(struct telnet_connection *t_con)
i = t_con->current_history + 1;
i %= TELNET_LINE_HISTORY_SIZE;
- while (t_con->history[i] == NULL && num > 0) {
+ while (!t_con->history[i] && num > 0) {
i++;
i %= TELNET_LINE_HISTORY_SIZE;
num--;
@@ -640,7 +640,7 @@ static int telnet_input(struct connection *connection)
/* save only non-blank not repeating lines in the history */
char *prev_line = t_con->history[(t_con->current_history > 0) ?
t_con->current_history - 1 : TELNET_LINE_HISTORY_SIZE-1];
- if (*t_con->line && (prev_line == NULL ||
+ if (*t_con->line && (!prev_line ||
strcmp(t_con->line, prev_line))) {
/* if the history slot is already taken, free it */
free(t_con->history[t_con->next_history]);
diff --git a/src/svf/svf.c b/src/svf/svf.c
index e12fbce..553bdc7 100644
--- a/src/svf/svf.c
+++ b/src/svf/svf.c
@@ -587,7 +587,7 @@ static int svf_getline(char **lineptr, size_t *n, FILE *stream)
#define MIN_CHUNK 16 /* Buffer is increased by this size each time as required */
size_t i = 0;
- if (*lineptr == NULL) {
+ if (!*lineptr) {
*n = MIN_CHUNK;
*lineptr = malloc(*n);
if (!*lineptr)
diff --git a/src/target/aarch64.c b/src/target/aarch64.c
index 43a13aa..70e727c 100644
--- a/src/target/aarch64.c
+++ b/src/target/aarch64.c
@@ -501,7 +501,7 @@ static int update_halt_gdb(struct target *target, enum target_debug_reason debug
}
/* after all targets were updated, poll the gdb serving target */
- if (gdb_target != NULL && gdb_target != target)
+ if (gdb_target && gdb_target != target)
aarch64_poll(gdb_target);
return ERROR_OK;
@@ -2855,7 +2855,7 @@ static int aarch64_jim_configure(struct target *target, struct jim_getopt_info *
return JIM_ERR;
}
- if (pc == NULL || pc->cti == NULL) {
+ if (!pc || !pc->cti) {
Jim_SetResultString(goi->interp, "CTI not configured", -1);
return JIM_ERR;
}
diff --git a/src/target/arc.c b/src/target/arc.c
index 1e8a515..4b546c3 100644
--- a/src/target/arc.c
+++ b/src/target/arc.c
@@ -1949,7 +1949,7 @@ static int arc_hit_watchpoint(struct target *target, struct watchpoint **hit_wat
LOG_WARNING("Target halted by breakpoint, but is treated as a watchpoint.");
for (struct watchpoint *watchpoint = target->watchpoints;
- watchpoint != NULL;
+ watchpoint;
watchpoint = watchpoint->next) {
if (actionpoint->bp_value == watchpoint->address) {
*hit_watchpoint = watchpoint;
diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c
index c458ffd..dc6f63d 100644
--- a/src/target/arm_adi_v5.c
+++ b/src/target/arm_adi_v5.c
@@ -1028,7 +1028,7 @@ int dap_lookup_cs_component(struct adiv5_ap *ap,
static int dap_read_part_id(struct adiv5_ap *ap, target_addr_t component_base, uint32_t *cid, uint64_t *pid)
{
assert((component_base & 0xFFF) == 0);
- assert(ap != NULL && cid != NULL && pid != NULL);
+ assert(ap && cid && pid);
uint32_t cid0, cid1, cid2, cid3;
uint32_t pid0, pid1, pid2, pid3, pid4;
diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h
index 8ebe963..5d1e793 100644
--- a/src/target/arm_adi_v5.h
+++ b/src/target/arm_adi_v5.h
@@ -446,7 +446,7 @@ static inline int dap_queue_dp_write(struct adiv5_dap *dap,
static inline int dap_queue_ap_read(struct adiv5_ap *ap,
unsigned reg, uint32_t *data)
{
- assert(ap->dap->ops != NULL);
+ assert(ap->dap->ops);
return ap->dap->ops->queue_ap_read(ap, reg, data);
}
@@ -462,7 +462,7 @@ static inline int dap_queue_ap_read(struct adiv5_ap *ap,
static inline int dap_queue_ap_write(struct adiv5_ap *ap,
unsigned reg, uint32_t data)
{
- assert(ap->dap->ops != NULL);
+ assert(ap->dap->ops);
return ap->dap->ops->queue_ap_write(ap, reg, data);
}
diff --git a/src/target/armv7a.c b/src/target/armv7a.c
index cc8c19a..6de79c3 100644
--- a/src/target/armv7a.c
+++ b/src/target/armv7a.c
@@ -483,7 +483,7 @@ int armv7a_identify_cache(struct target *target)
goto done;
/* if no l2 cache initialize l1 data cache flush function function */
- if (armv7a->armv7a_mmu.armv7a_cache.flush_all_data_cache == NULL) {
+ if (!armv7a->armv7a_mmu.armv7a_cache.flush_all_data_cache) {
armv7a->armv7a_mmu.armv7a_cache.flush_all_data_cache =
armv7a_cache_auto_flush_all_data;
}
diff --git a/src/target/armv7m.c b/src/target/armv7m.c
index ee05e47..68da020 100644
--- a/src/target/armv7m.c
+++ b/src/target/armv7m.c
@@ -474,7 +474,7 @@ int armv7m_get_gdb_reg_list(struct target *target, struct reg **reg_list[],
size = ARMV7M_NUM_CORE_REGS;
*reg_list = malloc(sizeof(struct reg *) * size);
- if (*reg_list == NULL)
+ if (!*reg_list)
return ERROR_FAIL;
for (i = 0; i < size; i++)
diff --git a/src/target/armv8.c b/src/target/armv8.c
index 86c0ebf..43a3659 100644
--- a/src/target/armv8.c
+++ b/src/target/armv8.c
@@ -204,7 +204,7 @@ static int armv8_read_reg(struct armv8_common *armv8, int regnum, uint64_t *regv
break;
}
- if (retval == ERROR_OK && regval != NULL)
+ if (retval == ERROR_OK && regval)
*regval = value_64;
else
retval = ERROR_FAIL;
@@ -430,7 +430,7 @@ static int armv8_read_reg32(struct armv8_common *armv8, int regnum, uint64_t *re
break;
}
- if (retval == ERROR_OK && regval != NULL)
+ if (retval == ERROR_OK && regval)
*regval = value;
return retval;
@@ -1053,7 +1053,7 @@ COMMAND_HANDLER(armv8_handle_exception_catch_command)
if (n->name)
nsec = n->name;
- if (sec == NULL || nsec == NULL) {
+ if (!sec || !nsec) {
LOG_WARNING("Exception Catch: unknown exception catch configuration: EDECCR = %02" PRIx32, edeccr & 0xff);
return ERROR_FAIL;
}
@@ -1644,7 +1644,7 @@ struct reg_cache *armv8_build_reg_cache(struct target *target)
reg_list[i].reg_data_type = calloc(1, sizeof(struct reg_data_type));
if (reg_list[i].reg_data_type) {
- if (armv8_regs[i].data_type == NULL)
+ if (!armv8_regs[i].data_type)
reg_list[i].reg_data_type->type = armv8_regs[i].type;
else
*reg_list[i].reg_data_type = *armv8_regs[i].data_type;
diff --git a/src/target/armv8_cache.c b/src/target/armv8_cache.c
index 86e4a59..b668b84 100644
--- a/src/target/armv8_cache.c
+++ b/src/target/armv8_cache.c
@@ -417,7 +417,7 @@ int armv8_identify_cache(struct armv8_common *armv8)
armv8->armv8_mmu.armv8_cache.info = 1;
/* if no l2 cache initialize l1 data cache flush function function */
- if (armv8->armv8_mmu.armv8_cache.flush_all_data_cache == NULL) {
+ if (!armv8->armv8_mmu.armv8_cache.flush_all_data_cache) {
armv8->armv8_mmu.armv8_cache.display_cache_info =
armv8_handle_inner_cache_info_command;
armv8->armv8_mmu.armv8_cache.flush_all_data_cache =
diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c
index f41f39d..8ef196e 100644
--- a/src/target/cortex_a.c
+++ b/src/target/cortex_a.c
@@ -704,7 +704,7 @@ static int update_halt_gdb(struct target *target)
}
/* after all targets were updated, poll the gdb serving target */
- if (gdb_target != NULL && gdb_target != target)
+ if (gdb_target && gdb_target != target)
cortex_a_poll(gdb_target);
return retval;
}
@@ -726,7 +726,7 @@ static int cortex_a_poll(struct target *target)
/* the next polling trigger an halt event sent to gdb */
if ((target->state == TARGET_HALTED) && (target->smp) &&
(target->gdb_service) &&
- (target->gdb_service->target == NULL)) {
+ (!target->gdb_service->target)) {
target->gdb_service->target =
get_cortex_a(target, target->gdb_service->core[1]);
target_call_event_callbacks(target, TARGET_EVENT_HALTED);
diff --git a/src/target/esirisc.c b/src/target/esirisc.c
index d17e1dd..e49f5f6 100644
--- a/src/target/esirisc.c
+++ b/src/target/esirisc.c
@@ -472,7 +472,7 @@ static int esirisc_next_breakpoint(struct target *target)
LOG_DEBUG("-");
for (int bp_index = 0; breakpoints_p < breakpoints_e; ++breakpoints_p, ++bp_index)
- if (*breakpoints_p == NULL)
+ if (!*breakpoints_p)
return bp_index;
return -1;
@@ -608,7 +608,7 @@ static int esirisc_next_watchpoint(struct target *target)
LOG_DEBUG("-");
for (int wp_index = 0; watchpoints_p < watchpoints_e; ++watchpoints_p, ++wp_index)
- if (*watchpoints_p == NULL)
+ if (!*watchpoints_p)
return wp_index;
return -1;
@@ -1267,7 +1267,7 @@ static const char *esirisc_get_gdb_arch(struct target *target)
* requires additional configuration to properly interact with these
* targets in GDB (also see: `esirisc cache_arch`).
*/
- if (esirisc->gdb_arch == NULL && target_was_examined(target))
+ if (!esirisc->gdb_arch && target_was_examined(target))
esirisc->gdb_arch = alloc_printf("esirisc:%d_bit_%d_reg_%s",
esirisc->num_bits, esirisc->num_regs, esirisc_cache_arch_name(esirisc));
@@ -1284,7 +1284,7 @@ static int esirisc_get_gdb_reg_list(struct target *target, struct reg **reg_list
*reg_list_size = ESIRISC_NUM_REGS;
*reg_list = calloc(*reg_list_size, sizeof(struct reg *));
- if (*reg_list == NULL)
+ if (!*reg_list)
return ERROR_FAIL;
if (reg_class == REG_CLASS_ALL)
diff --git a/src/target/esirisc_jtag.c b/src/target/esirisc_jtag.c
index 7fd35e5..dd5cd5a 100644
--- a/src/target/esirisc_jtag.c
+++ b/src/target/esirisc_jtag.c
@@ -57,7 +57,7 @@ static int esirisc_jtag_get_padding(void)
int padding = 0;
int bypass_devices = 0;
- for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap != NULL;
+ for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap;
tap = jtag_tap_next_enabled(tap))
if (tap->bypass)
bypass_devices++;
diff --git a/src/target/etm.c b/src/target/etm.c
index 05577ea..e8bd20f 100644
--- a/src/target/etm.c
+++ b/src/target/etm.c
@@ -298,7 +298,7 @@ struct reg_cache *etm_build_reg_cache(struct target *target,
reg_list = calloc(128, sizeof(struct reg));
arch_info = calloc(128, sizeof(struct etm_reg));
- if (reg_cache == NULL || reg_list == NULL || arch_info == NULL) {
+ if (!reg_cache || !reg_list || !arch_info) {
LOG_ERROR("No memory");
goto fail;
}
diff --git a/src/target/hla_target.c b/src/target/hla_target.c
index 78ec7e8..9186105 100644
--- a/src/target/hla_target.c
+++ b/src/target/hla_target.c
@@ -202,7 +202,7 @@ static int adapter_target_create(struct target *target,
{
LOG_DEBUG("%s", __func__);
struct adiv5_private_config *pc = target->private_config;
- if (pc != NULL && pc->ap_num > 0) {
+ if (pc && pc->ap_num > 0) {
LOG_ERROR("hla_target: invalid parameter -ap-num (> 0)");
return ERROR_COMMAND_SYNTAX_ERROR;
}
diff --git a/src/target/lakemont.c b/src/target/lakemont.c
index e3f331d..c30ac3b 100644
--- a/src/target/lakemont.c
+++ b/src/target/lakemont.c
@@ -381,7 +381,7 @@ struct reg_cache *lakemont_build_reg_cache(struct target *t)
struct reg_feature *feature;
int i;
- if (cache == NULL || reg_list == NULL || arch_info == NULL) {
+ if (!cache || !reg_list || !arch_info) {
free(cache);
free(reg_list);
free(arch_info);
@@ -1013,7 +1013,7 @@ int lakemont_resume(struct target *t, int current, target_addr_t address,
/* running away for a software breakpoint needs some special handling */
uint32_t eip = buf_get_u32(x86_32->cache->reg_list[EIP].value, 0, 32);
bp = breakpoint_find(t, eip);
- if (bp != NULL /*&& bp->type == BKPT_SOFT*/) {
+ if (bp /*&& bp->type == BKPT_SOFT*/) {
/* the step will step over the breakpoint */
if (lakemont_step(t, 0, 0, 1) != ERROR_OK) {
LOG_ERROR("%s stepping over a software breakpoint at 0x%08" PRIx32 " "
@@ -1024,12 +1024,12 @@ int lakemont_resume(struct target *t, int current, target_addr_t address,
/* if breakpoints are enabled, we need to redirect these into probe mode */
struct breakpoint *activeswbp = t->breakpoints;
- while (activeswbp != NULL && activeswbp->set == 0)
+ while (activeswbp && activeswbp->set == 0)
activeswbp = activeswbp->next;
struct watchpoint *activehwbp = t->watchpoints;
- while (activehwbp != NULL && activehwbp->set == 0)
+ while (activehwbp && activehwbp->set == 0)
activehwbp = activehwbp->next;
- if (activeswbp != NULL || activehwbp != NULL)
+ if (activeswbp || activehwbp)
buf_set_u32(x86_32->cache->reg_list[PMCR].value, 0, 32, 1);
if (do_resume(t) != ERROR_OK)
return ERROR_FAIL;
@@ -1054,7 +1054,7 @@ int lakemont_step(struct target *t, int current,
if (check_not_halted(t))
return ERROR_TARGET_NOT_HALTED;
bp = breakpoint_find(t, eip);
- if (retval == ERROR_OK && bp != NULL/*&& bp->type == BKPT_SOFT*/) {
+ if (retval == ERROR_OK && bp/*&& bp->type == BKPT_SOFT*/) {
/* TODO: This should only be done for software breakpoints.
* Stepping from hardware breakpoints should be possible with the resume flag
* Needs testing.
@@ -1105,7 +1105,7 @@ int lakemont_step(struct target *t, int current,
/* try to re-apply the breakpoint, even of step failed
* TODO: When a bp was set, we should try to stop the target - fix the return above
*/
- if (bp != NULL/*&& bp->type == BKPT_SOFT*/) {
+ if (bp/*&& bp->type == BKPT_SOFT*/) {
/* TODO: This should only be done for software breakpoints.
* Stepping from hardware breakpoints should be possible with the resume flag
* Needs testing.
diff --git a/src/target/ls1_sap.c b/src/target/ls1_sap.c
index 5e12188..c167224 100644
--- a/src/target/ls1_sap.c
+++ b/src/target/ls1_sap.c
@@ -184,7 +184,7 @@ static int ls1_sap_read_memory(struct target *target, target_addr_t address,
LOG_DEBUG("Reading memory at physical address 0x%" TARGET_PRIxADDR
"; size %" PRIu32 "; count %" PRIu32, address, size, count);
- if (count == 0 || buffer == NULL)
+ if (count == 0 || !buffer)
return ERROR_COMMAND_SYNTAX_ERROR;
ls1_sap_set_addr_high(target->tap, 0);
@@ -207,7 +207,7 @@ static int ls1_sap_write_memory(struct target *target, target_addr_t address,
"; size %" PRIu32 "; count %" PRIu32, address, size, count);
- if (count == 0 || buffer == NULL)
+ if (count == 0 || !buffer)
return ERROR_COMMAND_SYNTAX_ERROR;
ls1_sap_set_addr_high(target->tap, 0);
diff --git a/src/target/mem_ap.c b/src/target/mem_ap.c
index 424d6e7..eef05b4 100644
--- a/src/target/mem_ap.c
+++ b/src/target/mem_ap.c
@@ -238,7 +238,7 @@ static int mem_ap_read_memory(struct target *target, target_addr_t address,
LOG_DEBUG("Reading memory at physical address " TARGET_ADDR_FMT
"; size %" PRIu32 "; count %" PRIu32, address, size, count);
- if (count == 0 || buffer == NULL)
+ if (count == 0 || !buffer)
return ERROR_COMMAND_SYNTAX_ERROR;
return mem_ap_read_buf(mem_ap->ap, buffer, size, count, address);
@@ -253,7 +253,7 @@ static int mem_ap_write_memory(struct target *target, target_addr_t address,
LOG_DEBUG("Writing memory at physical address " TARGET_ADDR_FMT
"; size %" PRIu32 "; count %" PRIu32, address, size, count);
- if (count == 0 || buffer == NULL)
+ if (count == 0 || !buffer)
return ERROR_COMMAND_SYNTAX_ERROR;
return mem_ap_write_buf(mem_ap->ap, buffer, size, count, address);
diff --git a/src/target/mips_m4k.c b/src/target/mips_m4k.c
index 1a40293..cd06893 100644
--- a/src/target/mips_m4k.c
+++ b/src/target/mips_m4k.c
@@ -186,7 +186,7 @@ static int mips_m4k_poll(struct target *target)
/* the next polling trigger an halt event sent to gdb */
if ((target->state == TARGET_HALTED) && (target->smp) &&
(target->gdb_service) &&
- (target->gdb_service->target == NULL)) {
+ (!target->gdb_service->target)) {
target->gdb_service->target =
get_mips_m4k(target, target->gdb_service->core[1]);
target_call_event_callbacks(target, TARGET_EVENT_HALTED);
diff --git a/src/target/nds32_aice.c b/src/target/nds32_aice.c
index e494a3e..b01f8c0 100644
--- a/src/target/nds32_aice.c
+++ b/src/target/nds32_aice.c
@@ -24,7 +24,7 @@
int aice_read_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t *val)
{
- if (aice->port->api->read_reg_64 == NULL) {
+ if (!aice->port->api->read_reg_64) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -34,7 +34,7 @@ int aice_read_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t *val)
int aice_write_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t val)
{
- if (aice->port->api->write_reg_64 == NULL) {
+ if (!aice->port->api->write_reg_64) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -45,7 +45,7 @@ int aice_write_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t val)
int aice_read_tlb(struct aice_port_s *aice, target_addr_t virtual_address,
target_addr_t *physical_address)
{
- if (aice->port->api->read_tlb == NULL) {
+ if (!aice->port->api->read_tlb) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -55,7 +55,7 @@ int aice_read_tlb(struct aice_port_s *aice, target_addr_t virtual_address,
int aice_cache_ctl(struct aice_port_s *aice, uint32_t subtype, uint32_t address)
{
- if (aice->port->api->cache_ctl == NULL) {
+ if (!aice->port->api->cache_ctl) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -65,7 +65,7 @@ int aice_cache_ctl(struct aice_port_s *aice, uint32_t subtype, uint32_t address)
int aice_set_retry_times(struct aice_port_s *aice, uint32_t a_retry_times)
{
- if (aice->port->api->set_retry_times == NULL) {
+ if (!aice->port->api->set_retry_times) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -75,7 +75,7 @@ int aice_set_retry_times(struct aice_port_s *aice, uint32_t a_retry_times)
int aice_program_edm(struct aice_port_s *aice, char *command_sequence)
{
- if (aice->port->api->program_edm == NULL) {
+ if (!aice->port->api->program_edm) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -86,7 +86,7 @@ int aice_program_edm(struct aice_port_s *aice, char *command_sequence)
int aice_set_command_mode(struct aice_port_s *aice,
enum aice_command_mode command_mode)
{
- if (aice->port->api->set_command_mode == NULL) {
+ if (!aice->port->api->set_command_mode) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -97,7 +97,7 @@ int aice_set_command_mode(struct aice_port_s *aice,
int aice_execute(struct aice_port_s *aice, uint32_t *instructions,
uint32_t instruction_num)
{
- if (aice->port->api->execute == NULL) {
+ if (!aice->port->api->execute) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -107,7 +107,7 @@ int aice_execute(struct aice_port_s *aice, uint32_t *instructions,
int aice_set_custom_srst_script(struct aice_port_s *aice, const char *script)
{
- if (aice->port->api->set_custom_srst_script == NULL) {
+ if (!aice->port->api->set_custom_srst_script) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -117,7 +117,7 @@ int aice_set_custom_srst_script(struct aice_port_s *aice, const char *script)
int aice_set_custom_trst_script(struct aice_port_s *aice, const char *script)
{
- if (aice->port->api->set_custom_trst_script == NULL) {
+ if (!aice->port->api->set_custom_trst_script) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -127,7 +127,7 @@ int aice_set_custom_trst_script(struct aice_port_s *aice, const char *script)
int aice_set_custom_restart_script(struct aice_port_s *aice, const char *script)
{
- if (aice->port->api->set_custom_restart_script == NULL) {
+ if (!aice->port->api->set_custom_restart_script) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -137,7 +137,7 @@ int aice_set_custom_restart_script(struct aice_port_s *aice, const char *script)
int aice_set_count_to_check_dbger(struct aice_port_s *aice, uint32_t count_to_check)
{
- if (aice->port->api->set_count_to_check_dbger == NULL) {
+ if (!aice->port->api->set_count_to_check_dbger) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -148,7 +148,7 @@ int aice_set_count_to_check_dbger(struct aice_port_s *aice, uint32_t count_to_ch
int aice_profiling(struct aice_port_s *aice, uint32_t interval, uint32_t iteration,
uint32_t reg_no, uint32_t *samples, uint32_t *num_samples)
{
- if (aice->port->api->profiling == NULL) {
+ if (!aice->port->api->profiling) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c
index b93e549..24fb79c 100644
--- a/src/target/riscv/riscv-013.c
+++ b/src/target/riscv/riscv-013.c
@@ -4409,7 +4409,7 @@ void riscv013_clear_abstract_error(struct target *target)
#define COMPLIANCE_TEST(b, message) \
{ \
const char *last_sep = strrchr(__FILE__, FILE_SEP); \
- const char *fname = (last_sep == NULL ? __FILE__ : last_sep + 1); \
+ const char *fname = (!last_sep ? __FILE__ : last_sep + 1); \
LOG_INFO("Executing test %d (%s:%d): %s", total_tests, fname, __LINE__, message); \
int pass = 0; \
if (b) { \
diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c
index 74d59d2..8f1f398 100644
--- a/src/target/riscv/riscv.c
+++ b/src/target/riscv/riscv.c
@@ -2053,7 +2053,7 @@ int riscv_openocd_poll(struct target *target)
unsigned should_remain_halted = 0;
unsigned should_resume = 0;
unsigned i = 0;
- for (struct target_list *list = target->head; list != NULL;
+ for (struct target_list *list = target->head; list;
list = list->next, i++) {
total_targets++;
struct target *t = list->target;
@@ -3059,7 +3059,7 @@ int riscv_count_harts(struct target *target)
if (!target)
return 1;
RISCV_INFO(r);
- if (r == NULL || r->hart_count == NULL)
+ if (!r || !r->hart_count)
return 1;
return r->hart_count(target);
}
diff --git a/src/target/semihosting_common.c b/src/target/semihosting_common.c
index fa63903..5c96e1c 100644
--- a/src/target/semihosting_common.c
+++ b/src/target/semihosting_common.c
@@ -516,7 +516,7 @@ int semihosting_common(struct target *target)
uint64_t addr = semihosting_get_field(target, 0, fields);
size_t size = semihosting_get_field(target, 1, fields);
- char *arg = semihosting->cmdline != NULL ?
+ char *arg = semihosting->cmdline ?
semihosting->cmdline : "";
uint32_t len = strlen(arg) + 1;
if (len > size)
diff --git a/src/target/target.c b/src/target/target.c
index 9a476cb..686aa51 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -1397,7 +1397,7 @@ int target_hit_watchpoint(struct target *target,
return ERROR_TARGET_NOT_HALTED;
}
- if (target->type->hit_watchpoint == NULL) {
+ if (!target->type->hit_watchpoint) {
/* For backward compatible, if hit_watchpoint is not implemented,
* return ERROR_FAIL such that gdb_server will not take the nonsense
* information. */
@@ -1409,7 +1409,7 @@ int target_hit_watchpoint(struct target *target,
const char *target_get_gdb_arch(struct target *target)
{
- if (target->type->get_gdb_arch == NULL)
+ if (!target->type->get_gdb_arch)
return NULL;
return target->type->get_gdb_arch(target);
}
@@ -1573,19 +1573,19 @@ static int target_init_one(struct command_context *cmd_ctx,
type->virt2phys = identity_virt2phys;
}
- if (target->type->read_buffer == NULL)
+ if (!target->type->read_buffer)
target->type->read_buffer = target_read_buffer_default;
- if (target->type->write_buffer == NULL)
+ if (!target->type->write_buffer)
target->type->write_buffer = target_write_buffer_default;
- if (target->type->get_gdb_fileio_info == NULL)
+ if (!target->type->get_gdb_fileio_info)
target->type->get_gdb_fileio_info = target_get_gdb_fileio_info_default;
- if (target->type->gdb_fileio_end == NULL)
+ if (!target->type->gdb_fileio_end)
target->type->gdb_fileio_end = target_gdb_fileio_end_default;
- if (target->type->profiling == NULL)
+ if (!target->type->profiling)
target->type->profiling = target_profiling_default;
return ERROR_OK;
@@ -2120,7 +2120,7 @@ static int target_restore_working_area(struct target *target, struct working_are
{
int retval = ERROR_OK;
- if (target->backup_working_area && area->backup != NULL) {
+ if (target->backup_working_area && area->backup) {
retval = target_write_memory(target, area->address, 4, area->size / 4, area->backup);
if (retval != ERROR_OK)
LOG_ERROR("failed to restore %" PRIu32 " bytes of working area at address " TARGET_ADDR_FMT,
@@ -2555,7 +2555,7 @@ int target_blank_check_memory(struct target *target,
return ERROR_FAIL;
}
- if (target->type->blank_check_memory == NULL)
+ if (!target->type->blank_check_memory)
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
return target->type->blank_check_memory(target, blocks, num_blocks, erased_value);
@@ -3976,7 +3976,7 @@ static int handle_bp_command_set(struct command_invocation *cmd,
command_print(cmd, "breakpoint set at " TARGET_ADDR_FMT "", addr);
} else if (addr == 0) {
- if (target->type->add_context_breakpoint == NULL) {
+ if (!target->type->add_context_breakpoint) {
LOG_ERROR("Context breakpoint not available");
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
@@ -3986,7 +3986,7 @@ static int handle_bp_command_set(struct command_invocation *cmd,
command_print(cmd, "Context breakpoint set at 0x%8.8" PRIx32 "", asid);
} else {
- if (target->type->add_hybrid_breakpoint == NULL) {
+ if (!target->type->add_hybrid_breakpoint) {
LOG_ERROR("Hybrid breakpoint not available");
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
@@ -4791,7 +4791,7 @@ void target_handle_event(struct target *target, enum target_event e)
struct target_event_action *teap;
int retval;
- for (teap = target->event_action; teap != NULL; teap = teap->next) {
+ for (teap = target->event_action; teap; teap = teap->next) {
if (teap->event == e) {
LOG_DEBUG("target(%d): %s (%s) event: %d (%s) action: %s",
target->target_number,
@@ -4839,7 +4839,7 @@ bool target_has_event_action(struct target *target, enum target_event event)
{
struct target_event_action *teap;
- for (teap = target->event_action; teap != NULL; teap = teap->next) {
+ for (teap = target->event_action; teap; teap = teap->next) {
if (teap->event == event)
return true;
}
@@ -5729,7 +5729,7 @@ static int target_create(struct jim_getopt_info *goi)
break;
}
}
- if (target_types[x] == NULL) {
+ if (!target_types[x]) {
Jim_SetResultFormatted(goi->interp, "Unknown target type %s, try one of ", cp);
for (x = 0 ; target_types[x] ; x++) {
if (target_types[x + 1]) {
@@ -6154,7 +6154,7 @@ COMMAND_HANDLER(handle_fast_load_image_command)
fastload[i].address = image.sections[i].base_address + offset;
fastload[i].data = malloc(length);
- if (fastload[i].data == NULL) {
+ if (!fastload[i].data) {
free(buffer);
command_print(CMD, "error allocating buffer for section (%" PRIu32 " bytes)",
length);
diff --git a/src/target/target_request.c b/src/target/target_request.c
index cf588f4..bea9346 100644
--- a/src/target/target_request.c
+++ b/src/target/target_request.c
@@ -234,7 +234,7 @@ int delete_debug_msg_receiver(struct command_context *cmd_ctx, struct target *ta
if (c->cmd_ctx == cmd_ctx) {
*p = next;
free(c);
- if (*p == NULL) {
+ if (!*p) {
/* disable callback */
target->dbg_msg_enabled = 0;
}
@@ -256,7 +256,7 @@ COMMAND_HANDLER(handle_target_request_debugmsgs_command)
int receiving = 0;
- if (target->type->target_request_data == NULL) {
+ if (!target->type->target_request_data) {
LOG_ERROR("Target %s does not support target requests", target_name(target));
return ERROR_OK;
}
diff --git a/src/target/x86_32_common.c b/src/target/x86_32_common.c
index 0d1518c..a009bfe 100644
--- a/src/target/x86_32_common.c
+++ b/src/target/x86_32_common.c
@@ -75,7 +75,7 @@ int x86_32_get_gdb_reg_list(struct target *t,
*reg_list_size = x86_32->cache->num_regs;
LOG_DEBUG("num_regs=%d, reg_class=%d", (*reg_list_size), reg_class);
*reg_list = malloc(sizeof(struct reg *) * (*reg_list_size));
- if (*reg_list == NULL) {
+ if (!*reg_list) {
LOG_ERROR("%s out of memory", __func__);
return ERROR_FAIL;
}
@@ -258,7 +258,7 @@ int x86_32_common_write_phys_mem(struct target *t, target_addr_t phys_address,
/* update the breakpoint */
struct breakpoint *pbiter = t->breakpoints;
- while (pbiter != NULL && pbiter->unique_id != iter->swbp_unique_id)
+ while (pbiter && pbiter->unique_id != iter->swbp_unique_id)
pbiter = pbiter->next;
if (pbiter)
pbiter->orig_instr[0] = buffer[offset];
@@ -456,7 +456,7 @@ int calcaddr_physfromlin(struct target *t, target_addr_t addr, target_addr_t *ph
{
uint8_t entry_buffer[8];
- if (physaddr == NULL || t == NULL)
+ if (!physaddr || !t)
return ERROR_FAIL;
struct x86_32_common *x86_32 = target_to_x86_32(t);
@@ -1113,7 +1113,7 @@ static int unset_swbp(struct target *t, struct breakpoint *bp)
x86_32->swbbp_mem_patch_list = iter->next;
free(iter);
} else {
- while (iter->next != NULL && iter->next->swbp_unique_id != bp->unique_id)
+ while (iter->next && iter->next->swbp_unique_id != bp->unique_id)
iter = iter->next;
if (iter->next) {
/* it's the next one */
diff --git a/src/transport/transport.c b/src/transport/transport.c
index 5ec8b87..ba1af33 100644
--- a/src/transport/transport.c
+++ b/src/transport/transport.c
@@ -106,7 +106,7 @@ int allow_transports(struct command_context *ctx, const char * const *vector)
* of one transport; C code should be definitive about what
* can be used when all goes well.
*/
- if (allowed_transports != NULL || session) {
+ if (allowed_transports || session) {
LOG_ERROR("Can't modify the set of allowed transports.");
return ERROR_FAIL;
}