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);
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);
{
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) {
{
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) {
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,
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)
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;
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,
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)
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;
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]);
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;
/* 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;
}
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;
}
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;
}
}
/* 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;
}
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",
/* 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! */
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");
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 */
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;
}
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;
}
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.
*
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
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);
}
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);
}
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)
unsigned jtag_num_taps = 0;
struct jtag_tap **tap = &__jtag_all_taps;
- while (*tap != NULL) {
+ while (*tap) {
jtag_num_taps++;
tap = &(*tap)->next_tap;
}
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,
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'");
}
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");
/* 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)
/* 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) {
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++;
}
/* 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) {
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;
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;
}
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)
goto skip;
}
- if (swd_cmd_queue[i].dst != NULL)
+ if (swd_cmd_queue[i].dst)
*swd_cmd_queue[i].dst = data;
}
}
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:
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:
}
/* 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);
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
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;
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);
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);
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;
/*
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];
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:
}
/* 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);
}
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);
}
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);
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) {
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;
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;
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;
{
*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));
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))) {
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;
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;
}
/* 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))
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))
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;
}
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;
{
t->next = NULL;
- if (*last == NULL)
+ if (!*last)
if (!task_list) {
task_list = t;
return task_list;
)
{
if (
- (target->rtos->symbols != NULL) &&
+ (target->rtos->symbols) &&
(target->rtos->symbols[MQX_VAL_MQX_KERNEL_DATA].address != 0)
) {
return true;
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;
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;
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;
{
*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;
}
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;
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) {
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) {
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);
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;
}
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;
}
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;
}
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;
}
}
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,
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;
}
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]);
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;
/* Extract the annex if needed */
if (annex) {
*annex = strndup(buf, annex_end - buf);
- if (*annex == NULL)
+ if (!*annex)
return ERROR_FAIL;
}
{
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;
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
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,
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);
transfer_type = 'l';
*chunk = malloc(length + 2);
- if (*chunk == NULL) {
+ if (!*chunk) {
LOG_ERROR("Unable to allocate memory");
return ERROR_FAIL;
}
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");
* 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;
}
/* 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;
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);
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 {
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 {
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--;
/* 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]);
#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)
}
/* 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;
return JIM_ERR;
}
- if (pc == NULL || pc->cti == NULL) {
+ if (!pc || !pc->cti) {
Jim_SetResultString(goi->interp, "CTI not configured", -1);
return JIM_ERR;
}
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;
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;
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);
}
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);
}
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;
}
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++)
break;
}
- if (retval == ERROR_OK && regval != NULL)
+ if (retval == ERROR_OK && regval)
*regval = value_64;
else
retval = ERROR_FAIL;
break;
}
- if (retval == ERROR_OK && regval != NULL)
+ if (retval == ERROR_OK && regval)
*regval = value;
return retval;
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;
}
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;
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 =
}
/* 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;
}
/* 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);
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;
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;
* 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));
*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)
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++;
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;
}
{
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;
}
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);
/* 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 " "
/* 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;
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.
/* 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.
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);
"; 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);
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);
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);
/* 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);
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
#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) { \
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;
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);
}
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)
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. */
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);
}
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;
{
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,
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);
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;
}
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;
}
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,
{
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;
}
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]) {
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);
if (c->cmd_ctx == cmd_ctx) {
*p = next;
free(c);
- if (*p == NULL) {
+ if (!*p) {
/* disable callback */
target->dbg_msg_enabled = 0;
}
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;
}
*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;
}
/* 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];
{
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);
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 */
* 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;
}