unsigned get_flash_name_index(const char *name)
{
const char *name_index = strrchr(name, '.');
- if (NULL == name_index)
+ if (!name_index)
return 0;
if (name_index[1] < '0' || name_index[1] > '9')
return ~0U;
}
info = calloc(1, sizeof(*info));
- if (info == NULL)
+ if (!info)
goto fail;
info->eccmode = eccmode;
duration_start(&state->bench);
- if (NULL != filename) {
+ if (filename) {
int retval = fileio_open(&state->fileio, filename, filemode, FILEIO_BINARY);
if (retval != ERROR_OK) {
const char *msg = (filemode == FILEIO_READ) ? "read" : "write";
if (retval != ERROR_OK)
return retval;
- if (NULL == nand->device) {
+ if (!nand->device) {
command_print(CMD, "#%s: not probed", CMD_ARGV[0]);
return ERROR_NAND_DEVICE_NOT_PROBED;
}
size_t total_read = 0;
size_t one_read;
- if (NULL != s->page) {
+ if (s->page) {
fileio_read(s->fileio, s->page_size, s->page, &one_read);
if (one_read < s->page_size)
memset(s->page + one_read, 0xff, s->page_size - one_read);
nand_calculate_ecc_kw(nand, s->page + i, ecc);
ecc += 10;
}
- } else if (NULL != s->oob) {
+ } else if (s->oob) {
fileio_read(s->fileio, s->oob_size, s->oob, &one_read);
if (one_read < s->oob_size)
memset(s->oob + one_read, 0xff, s->oob_size - one_read);
{
struct mx3_nf_controller *mx3_nf_info;
mx3_nf_info = malloc(sizeof(struct mx3_nf_controller));
- if (mx3_nf_info == NULL) {
+ if (!mx3_nf_info) {
LOG_ERROR("no memory for nand controller");
return ERROR_FAIL;
}
int hwecc_needed;
mxc_nf_info = malloc(sizeof(struct mxc_nf_controller));
- if (mxc_nf_info == NULL) {
+ if (!mxc_nf_info) {
LOG_ERROR("no memory for nand controller");
return ERROR_FAIL;
}
struct s3c24xx_nand_controller *s3c24xx_info;
s3c24xx_info = malloc(sizeof(struct s3c24xx_nand_controller));
- if (s3c24xx_info == NULL) {
+ if (!s3c24xx_info) {
LOG_ERROR("no memory for nand controller");
return -ENOMEM;
}
if (retval != ERROR_OK)
return retval;
- if (NULL == p->device) {
+ if (!p->device) {
command_print(CMD, "#%s: not probed", CMD_ARGV[0]);
return ERROR_OK;
}
return retval;
}
- if (NULL != s.page)
+ if (s.page)
fileio_write(s.fileio, s.page_size, s.page, &size_written);
- if (NULL != s.oob)
+ if (s.oob)
fileio_write(s.fileio, s.oob_size, s.oob, &size_written);
s.size -= nand->page_size;
if (retval != ERROR_OK)
return retval;
- if (NULL == p->device) {
+ if (!p->device) {
command_print(CMD, "#%s: not probed", CMD_ARGV[0]);
return ERROR_OK;
}
return ERROR_COMMAND_ARGUMENT_INVALID;
}
- if (NULL != controller->commands) {
+ if (controller->commands) {
retval = register_commands(CMD_CTX, NULL,
controller->commands);
if (retval != ERROR_OK)
return retval;
}
c = malloc(sizeof(struct nand_device));
- if (c == NULL) {
+ if (!c) {
LOG_ERROR("End of memory");
return ERROR_FAIL;
}
return retval;
}
- if (controller->usage == NULL)
+ if (!controller->usage)
LOG_DEBUG("'%s' driver usage field missing", controller->name);
nand_device_add(c);
const char *driver_name = CMD_ARGV[0];
struct nand_flash_controller *controller;
controller = nand_driver_find_by_name(CMD_ARGV[0]);
- if (NULL == controller) {
+ if (!controller) {
LOG_ERROR("No valid NAND flash driver found (%s)", driver_name);
return CALL_COMMAND_HANDLER(handle_nand_list_drivers);
}
{
struct sam3_chip *chip;
- if (target == NULL)
+ if (!target)
return NULL;
chip = all_sam3_chips;
else
details++;
}
- if (details->name == NULL) {
+ if (!details->name) {
LOG_ERROR("SAM3 ChipID 0x%08x not found in table (perhaps you can ID this chip?)",
(unsigned int)(private->chip->cfg.CHIPID_CIDR));
/* Help the victim, print details about the chip */
}
}
- if (bank->sectors == NULL) {
+ if (!bank->sectors) {
bank->sectors = calloc(private->nsectors, (sizeof((bank->sectors)[0])));
- if (bank->sectors == NULL) {
+ if (!bank->sectors) {
LOG_ERROR("No memory!");
return ERROR_FAIL;
}
{
struct sam4_chip *chip;
- if (target == NULL)
+ if (!target)
return NULL;
chip = all_sam4_chips;
else
details++;
}
- if (details->name == NULL) {
+ if (!details->name) {
LOG_ERROR("SAM4 ChipID 0x%08x not found in table (perhaps you can ID this chip?)",
(unsigned int)(private->chip->cfg.CHIPID_CIDR));
/* Help the victim, print details about the chip */
int k = bank->size / 1024;
private = get_sam4_bank_private(bank);
- if (private == NULL)
+ if (!private)
return ERROR_FAIL;
command_print_sameline(cmd, "%s bank %d: %d kB at " TARGET_ADDR_FMT,
}
}
- if (bank->sectors == NULL) {
+ if (!bank->sectors) {
bank->sectors = calloc(private->nsectors, (sizeof((bank->sectors)[0])));
- if (bank->sectors == NULL) {
+ if (!bank->sectors) {
LOG_ERROR("No memory!");
return ERROR_FAIL;
}
{
uint8_t devsel = SAMD_GET_DEVSEL(id);
const struct samd_family *family = samd_find_family(id);
- if (family == NULL)
+ if (!family)
return NULL;
for (unsigned i = 0; i < family->num_parts; i++) {
}
part = samd_find_part(id);
- if (part == NULL) {
+ if (!part) {
LOG_ERROR("Couldn't find part corresponding to DID %08" PRIx32, id);
return ERROR_FAIL;
}
}
const struct samd_family *family;
family = samd_find_family(id);
- if (family == NULL) {
+ if (!family) {
LOG_ERROR("Couldn't determine device family");
return ERROR_FAIL;
}
{
uint8_t devsel = SAMD_GET_DEVSEL(id);
const struct samd_family *family = samd_find_family(id);
- if (family == NULL)
+ if (!family)
return NULL;
for (unsigned i = 0; i < family->num_parts; i++) {
}
part = samd_find_part(id);
- if (part == NULL) {
+ if (!part) {
LOG_ERROR("Couldn't find part corresponding to DID %08" PRIx32, id);
return ERROR_FAIL;
}
}
}
- if (avr_info != NULL) {
+ if (avr_info) {
free(bank->sectors);
/* chip found */
}
}
- if (avr_info != NULL) {
+ if (avr_info) {
/* chip found */
command_print_sameline(cmd, "%s - Rev: 0x%" PRIx32 "", avr_info->name,
EXTRACT_VER(device_id));
bluenrgx_info = calloc(1, sizeof(*bluenrgx_info));
/* Check allocation */
- if (bluenrgx_info == NULL) {
+ if (!bluenrgx_info) {
LOG_ERROR("failed to allocate bank structure");
return ERROR_FAIL;
}
return retval;
/* Check for working area to use for flash helper algorithm */
- if (NULL != cc26xx_bank->working_area)
+ if (cc26xx_bank->working_area)
target_free_working_area(target, cc26xx_bank->working_area);
retval = target_alloc_working_area(target, cc26xx_bank->algo_working_size,
&cc26xx_bank->working_area);
return ERROR_COMMAND_SYNTAX_ERROR;
cc26xx_bank = malloc(sizeof(struct cc26xx_bank));
- if (NULL == cc26xx_bank)
+ if (!cc26xx_bank)
return ERROR_FAIL;
/* Initialize private flash information */
num_sectors = max_sectors;
bank->sectors = malloc(sizeof(struct flash_sector) * num_sectors);
- if (NULL == bank->sectors)
+ if (!bank->sectors)
return ERROR_FAIL;
bank->base = CC26XX_FLASH_BASE_ADDR;
return ERROR_COMMAND_SYNTAX_ERROR;
cc3220sf_bank = malloc(sizeof(struct cc3220sf_bank));
- if (NULL == cc3220sf_bank)
+ if (!cc3220sf_bank)
return ERROR_FAIL;
/* Initialize private flash information */
free(bank->sectors);
bank->sectors = malloc(sizeof(struct flash_sector) * num_sectors);
- if (NULL == bank->sectors)
+ if (!bank->sectors)
return ERROR_FAIL;
bank->base = base;
free(cfi_info->pri_ext);
pri_ext = malloc(sizeof(struct cfi_intel_pri_ext));
- if (pri_ext == NULL) {
+ if (!pri_ext) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
free(cfi_info->pri_ext);
pri_ext = malloc(sizeof(struct cfi_spansion_pri_ext));
- if (pri_ext == NULL) {
+ if (!pri_ext) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
free(cfi_info->pri_ext);
pri_ext = malloc(sizeof(struct cfi_spansion_pri_ext));
- if (pri_ext == NULL) {
+ if (!pri_ext) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
}
cfi_info = calloc(1, sizeof(struct cfi_flash_bank));
- if (cfi_info == NULL) {
+ if (!cfi_info) {
LOG_ERROR("No memory for flash bank info");
return ERROR_FAIL;
}
/* convert bus-width dependent algorithm code to correct endianness */
target_code = malloc(target_code_size);
- if (target_code == NULL) {
+ if (!target_code) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
/* convert bus-width dependent algorithm code to correct endianness */
target_code = malloc(target_code_size);
- if (target_code == NULL) {
+ if (!target_code) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
if (flash_banks) {
/* find last flash bank */
struct flash_bank *p = flash_banks;
- while (NULL != p->next) {
+ while (p->next) {
bank_num += 1;
p = p->next;
}
int retval;
bank = get_flash_bank_by_name_noprobe(name);
- if (bank != NULL) {
+ if (bank) {
retval = bank->driver->auto_probe(bank);
if (retval != ERROR_OK) {
struct flash_bank *p = get_flash_bank_by_num_noprobe(num);
int retval;
- if (p == NULL)
+ if (!p)
return ERROR_FAIL;
retval = p->driver->auto_probe(p);
struct target_memory_check_block *block_array;
block_array = malloc(bank->num_sectors * sizeof(struct target_memory_check_block));
- if (block_array == NULL)
+ if (!block_array)
return default_flash_mem_blank_check(bank);
for (unsigned int i = 0; i < bank->num_sectors; i++) {
retval = get_flash_bank_by_addr(target, run_address, false, &c);
if (retval != ERROR_OK)
goto done;
- if (c == NULL) {
+ if (!c) {
LOG_WARNING("no flash bank found for address " TARGET_ADDR_FMT, run_address);
section++; /* and skip it */
section_offset = 0;
/* allocate buffer */
buffer = malloc(run_size);
- if (buffer == NULL) {
+ if (!buffer) {
LOG_ERROR("Out of memory for flash bank buffer");
retval = ERROR_FAIL;
goto done;
goto done;
}
- if (written != NULL)
+ if (written)
*written += run_size; /* add run size to total written counter */
}
unsigned int num_blocks)
{
struct flash_sector *array = calloc(num_blocks, sizeof(struct flash_sector));
- if (array == NULL)
+ if (!array)
return NULL;
for (unsigned int i = 0; i < num_blocks; i++) {
efm32_info->family_data = &efm32_families[i];
}
- if (efm32_info->family_data == NULL) {
+ if (!efm32_info->family_data) {
LOG_ERROR("Unknown MCU family %d", efm32_info->part_family);
return ERROR_FAIL;
}
uint32_t old_count = count;
count = (old_count | 3) + 1;
new_buffer = malloc(count);
- if (new_buffer == NULL) {
+ if (!new_buffer) {
LOG_ERROR("odd number of bytes to write and no memory "
"for padding buffer");
return ERROR_FAIL;
return ret;
}
- assert(NULL != bank->sectors);
+ assert(bank->sectors);
for (unsigned int i = 0; i < bank->num_sectors; i++)
bank->sectors[i].is_protected = efm32x_get_page_lock(bank, i);
return ERROR_COMMAND_SYNTAX_ERROR;
info = malloc(sizeof(struct faux_flash_bank));
- if (info == NULL) {
+ if (!info) {
LOG_ERROR("no memory for flash bank info");
return ERROR_FAIL;
}
info->memory = malloc(bank->size);
- if (info->memory == NULL) {
+ if (!info->memory) {
free(info);
LOG_ERROR("no memory for flash bank info");
return ERROR_FAIL;
}
info->target = get_target(CMD_ARGV[5]);
- if (info->target == NULL) {
+ if (!info->target) {
LOG_ERROR("target '%s' not defined", CMD_ARGV[5]);
free(info->memory);
free(info);
return ERROR_COMMAND_SYNTAX_ERROR;
fespi_info = malloc(sizeof(struct fespi_flash_bank));
- if (fespi_info == NULL) {
+ if (!fespi_info) {
LOG_ERROR("not enough memory");
return ERROR_FAIL;
}
/* create and fill sectors array */
bank->num_sectors = fespi_info->dev->size_in_bytes / sectorsize;
sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
- if (sectors == NULL) {
+ if (!sectors) {
LOG_ERROR("not enough memory");
return ERROR_FAIL;
}
return ERROR_COMMAND_SYNTAX_ERROR;
info = malloc(sizeof(struct jtagspi_flash_bank));
- if (info == NULL) {
+ if (!info) {
LOG_ERROR("no memory for flash bank info");
return ERROR_FAIL;
}
lenb = DIV_ROUND_UP(len, 8);
data_buf = malloc(lenb);
if (lenb > 0) {
- if (data_buf == NULL) {
+ if (!data_buf) {
LOG_ERROR("no memory for spi buffer");
return ERROR_FAIL;
}
/* create and fill sectors array */
bank->num_sectors = info->dev->size_in_bytes / sectorsize;
sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
- if (sectors == NULL) {
+ if (!sectors) {
LOG_ERROR("not enough memory");
return ERROR_FAIL;
}
k_chip = kinetis_get_chip(target);
- if (k_chip == NULL) {
+ if (!k_chip) {
k_chip = calloc(sizeof(struct kinetis_chip), 1);
- if (k_chip == NULL) {
+ if (!k_chip) {
LOG_ERROR("No memory");
return ERROR_FAIL;
}
static void kinetis_free_driver_priv(struct flash_bank *bank)
{
struct kinetis_flash_bank *k_bank = bank->driver_priv;
- if (k_bank == NULL)
+ if (!k_bank)
return;
struct kinetis_chip *k_chip = k_bank->k_chip;
- if (k_chip == NULL)
+ if (!k_chip)
return;
k_chip->num_banks--;
}
bank = calloc(sizeof(struct flash_bank), 1);
- if (bank == NULL)
+ if (!bank)
return ERROR_FAIL;
bank->target = k_chip->target;
struct target *target = get_current_target(CMD_CTX);
struct kinetis_chip *k_chip = kinetis_get_chip(target);
- if (k_chip == NULL)
+ if (!k_chip)
return ERROR_FAIL;
if (CMD_ARGC > 0)
k_bank = &(k_chip->banks[bank_idx]);
bank_iter = k_bank->bank;
- if (bank_iter == NULL) {
+ if (!bank_iter) {
LOG_WARNING("Missing bank %u configuration, FCF protection flags may be incomplete", bank_idx);
continue;
}
uint8_t pmstat;
struct target *target;
- if (k_chip == NULL) {
+ if (!k_chip) {
LOG_ERROR("Chip not probed.");
return ERROR_FAIL;
}
uint32_t old_count = count;
count = (old_count | 3) + 1;
new_buffer = malloc(count);
- if (new_buffer == NULL) {
+ if (!new_buffer) {
LOG_ERROR("odd number of bytes to write and no memory "
"for padding buffer");
return ERROR_FAIL;
}
switch (sz_type) {
case SHOW_INFO:
- if (k_chip == NULL) {
+ if (!k_chip) {
LOG_ERROR("Chip not probed.");
return ERROR_FAIL;
}
if (result != ERROR_OK)
return result;
- assert(bank != NULL);
+ assert(bank);
if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
uint32_t old_count = count;
count = (old_count | 3) + 1;
new_buffer = malloc(count);
- if (new_buffer == NULL) {
+ if (!new_buffer) {
LOG_ERROR("odd number of bytes to write and no memory "
"for padding buffer");
return ERROR_FAIL;
return ERROR_COMMAND_SYNTAX_ERROR;
lpcspifi_info = malloc(sizeof(struct lpcspifi_flash_bank));
- if (lpcspifi_info == NULL) {
+ if (!lpcspifi_info) {
LOG_ERROR("not enough memory");
return ERROR_FAIL;
}
/* create and fill sectors array */
bank->num_sectors = lpcspifi_info->dev->size_in_bytes / sectorsize;
sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
- if (sectors == NULL) {
+ if (!sectors) {
LOG_ERROR("not enough memory");
return ERROR_FAIL;
}
int rem = count % 4;
if (rem) {
new_buffer = malloc(count + rem);
- if (new_buffer == NULL) {
+ if (!new_buffer) {
LOG_ERROR("odd number of bytes to write and no memory for padding buffer");
return ERROR_FAIL;
}
/* create and fill sectors array */
bank->num_sectors = mrvlqspi_info->dev->size_in_bytes / sectorsize;
sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
- if (sectors == NULL) {
+ if (!sectors) {
LOG_ERROR("not enough memory");
return ERROR_FAIL;
}
return ERROR_COMMAND_SYNTAX_ERROR;
mrvlqspi_info = malloc(sizeof(struct mrvlqspi_flash_bank));
- if (mrvlqspi_info == NULL) {
+ if (!mrvlqspi_info) {
LOG_ERROR("not enough memory");
return ERROR_FAIL;
}
}
/* Check for working area to use for flash helper algorithm */
- if (NULL != msp432_bank->working_area)
+ if (msp432_bank->working_area)
target_free_working_area(target, msp432_bank->working_area);
retval = target_alloc_working_area(target, ALGO_WORKING_SIZE,
&msp432_bank->working_area);
/* Create shared private struct for flash banks */
msp432_bank = malloc(sizeof(struct msp432_bank));
- if (NULL == msp432_bank)
+ if (!msp432_bank)
return ERROR_FAIL;
/* Initialize private flash information */
if (num_sectors > 0) {
bank->sectors = malloc(sizeof(struct flash_sector) * num_sectors);
- if (NULL == bank->sectors)
+ if (!bank->sectors)
return ERROR_FAIL;
}
if (is_main && MSP432P4 == msp432_bank->family_type) {
/* Create the info flash bank needed by MSP432P4 variants */
struct flash_bank *info = calloc(sizeof(struct flash_bank), 1);
- if (NULL == info)
+ if (!info)
return ERROR_FAIL;
/* Create a name for the info bank, append "_1" to main name */
int rem = count % 16;
if (rem) {
new_buffer = malloc(count + 16 - rem);
- if (new_buffer == NULL) {
+ if (!new_buffer) {
LOG_ERROR("Odd number of words to write and no memory for padding buffer");
return ERROR_FAIL;
}
{
struct nrf5_bank *nbank = bank->driver_priv;
- assert(nbank != NULL);
+ assert(nbank);
return nbank->probed;
}
struct nrf5_bank *nbank = bank->driver_priv;
struct nrf5_info *chip = nbank->chip;
- assert(chip != NULL);
+ assert(chip);
res = target_read_u32(chip->target, NRF51_FICR_CLENR0,
&clenr0);
struct nrf5_bank *nbank = bank->driver_priv;
struct nrf5_info *chip = nbank->chip;
- assert(chip != NULL);
+ assert(chip);
static uint32_t nrf5_bprot_offsets[4] = { 0x600, 0x604, 0x610, 0x614 };
uint32_t bprot_reg = 0;
struct nrf5_bank *nbank = bank->driver_priv;
struct nrf5_info *chip = nbank->chip;
- assert(chip != NULL);
+ assert(chip);
if (chip->features & NRF5_FEATURE_BPROT)
return nrf5_protect_check_bprot(bank);
{
struct nrf5_bank *nbank = bank->driver_priv;
struct nrf5_info *chip = nbank->chip;
- if (chip == NULL)
+ if (!chip)
return;
chip->refcount--;
nbank = &chip->bank[1];
break;
}
- assert(nbank != NULL);
+ assert(nbank);
chip->refcount++;
nbank->chip = chip;
if (res != ERROR_OK)
return res;
- assert(bank != NULL);
+ assert(bank);
struct nrf5_info *chip;
if (res != ERROR_OK)
return res;
- assert(bank != NULL);
+ assert(bank);
struct nrf5_info *chip;
init_reg_param(®_params[2], "r2", 32, PARAM_OUT); /* number of words to program */
struct armv7m_common *armv7m = target_to_armv7m(target);
- if (armv7m == NULL) {
+ if (!armv7m) {
/* something is very wrong if armv7m is NULL */
LOG_ERROR("unable to get armv7m target");
return retval;
uint8_t *new_buffer = NULL;
if (row_offset && (count >= (row_size / 4))) {
new_buffer = malloc(buffer_size);
- if (new_buffer == NULL) {
+ if (!new_buffer) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
sysreq_wait_algorithm->address + sysreq_wait_algorithm->size);
struct armv7m_common *armv7m = target_to_armv7m(target);
- if (armv7m == NULL) {
+ if (!armv7m) {
/* something is very wrong if armv7m is NULL */
LOG_ERROR("unable to get armv7m target");
retval = ERROR_FAIL;
int prot_sz = num_bits / 8;
sysrq_buffer = malloc(param_sz + prot_sz);
- if (sysrq_buffer == NULL) {
+ if (!sysrq_buffer) {
LOG_ERROR("no memory for row buffer");
return ERROR_FAIL;
}
return retval;
sysrq_buffer = malloc(param_sz + psoc4_info->row_size);
- if (sysrq_buffer == NULL) {
+ if (!sysrq_buffer) {
LOG_ERROR("no memory for row buffer");
return ERROR_FAIL;
}
bank->size = num_rows * row_size;
bank->num_sectors = num_rows;
bank->sectors = alloc_block_array(0, row_size, num_rows);
- if (bank->sectors == NULL)
+ if (!bank->sectors)
return ERROR_FAIL;
LOG_DEBUG("flash bank set %" PRIu32 " rows", num_rows);
struct target_memory_check_block *block_array;
block_array = malloc(num_sectors * sizeof(struct target_memory_check_block));
- if (block_array == NULL)
+ if (!block_array)
return ERROR_FAIL;
for (unsigned int i = 0; i < num_sectors; i++) {
nph = ((header.revision >> 16) & 0xFF) + 1;
LOG_DEBUG("parameter headers: %d", nph);
pheaders = malloc(sizeof(struct sfdp_phdr) * nph);
- if (pheaders == NULL) {
+ if (!pheaders) {
LOG_ERROR("not enough memory");
return ERROR_FAIL;
}
/* retrieve parameter table */
ptable = malloc(words << 2);
- if (ptable == NULL) {
+ if (!ptable) {
LOG_ERROR("not enough memory");
retval = ERROR_FAIL;
goto err;
count++;
new_buffer = malloc(count);
- if (new_buffer == NULL) {
+ if (!new_buffer) {
LOG_ERROR("odd number of bytes to write and no memory "
"for padding buffer");
return ERROR_FAIL;
struct cortex_m_common *cortex_m = target_to_cm(target);
struct adiv5_dap *dap = cortex_m->armv7m.arm.dap;
- if (dap == NULL) {
+ if (!dap) {
/* Used debug interface doesn't support direct DAP access */
LOG_ERROR("mass_erase can't be used by this debug interface");
return ERROR_FAIL;
struct cortex_m_common *cortex_m = target_to_cm(target);
struct adiv5_dap *dap = cortex_m->armv7m.arm.dap;
- if (dap == NULL) {
+ if (!dap) {
/* Used debug interface doesn't support direct DAP access */
LOG_INFO("Target can't by unlocked by this debug interface");
LOG_ERROR("Unexpected lock word value");
/* SIM3X_AP_ID_VALUE is not checked */
- if (dap == NULL)
+ if (!dap)
LOG_INFO("Maybe this isn't a SiM3x MCU");
return ERROR_FAIL;
* discrete accesses. */
if (count & 1) {
new_buffer = malloc(count + 1);
- if (new_buffer == NULL) {
+ if (!new_buffer) {
LOG_ERROR("odd number of bytes to write and no memory for padding buffer");
return ERROR_FAIL;
}
return ERROR_FAIL;
}
- if (rev_str != NULL)
+ if (rev_str)
command_print_sameline(cmd, "%s - Rev: %s", device_str, rev_str);
else
command_print_sameline(cmd, "%s - Rev: unknown (0x%04x)", device_str, rev_id);
return ERROR_FAIL;
}
- if (rev_str != NULL)
+ if (rev_str)
command_print_sameline(cmd, "%s - Rev: %s", device_str, rev_str);
else
command_print_sameline(cmd, "%s - Rev: unknown (0x%04" PRIx16 ")", device_str, rev_id);
bank->sectors = alloc_block_array(0, stm32x_info->part_info->page_size_kb * 1024,
bank->num_sectors);
- if (bank->sectors == NULL) {
+ if (!bank->sectors) {
LOG_ERROR("failed to allocate bank sectors");
return ERROR_FAIL;
}
bank->prot_blocks = alloc_block_array(0, stm32x_info->part_info->page_size_kb * wpsn * 1024,
bank->num_prot_blocks);
- if (bank->prot_blocks == NULL) {
+ if (!bank->prot_blocks) {
LOG_ERROR("failed to allocate bank prot_block");
return ERROR_FAIL;
}
if (rev_id == info->revs[i].rev)
rev_str = info->revs[i].str;
- if (rev_str != NULL) {
+ if (rev_str) {
command_print_sameline(cmd, "%s - Rev: %s",
stm32x_info->part_info->device_str, rev_str);
} else {
bank->size = (flash_size_kb + gap_size_kb) * 1024;
bank->num_sectors = num_pages;
bank->sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
- if (bank->sectors == NULL) {
+ if (!bank->sectors) {
LOG_ERROR("failed to allocate bank sectors");
return ERROR_FAIL;
}
stm32lx_info = calloc(1, sizeof(*stm32lx_info));
/* Check allocation */
- if (stm32lx_info == NULL) {
+ if (!stm32lx_info) {
LOG_ERROR("failed to allocate bank structure");
return ERROR_FAIL;
}
}
struct armv7m_common *armv7m = target_to_armv7m(target);
- if (armv7m == NULL) {
+ if (!armv7m) {
/* something is very wrong if armv7m is NULL */
LOG_ERROR("unable to get armv7m target");
bank->base = base_address;
bank->num_sectors = num_sectors;
bank->sectors = malloc(sizeof(struct flash_sector) * num_sectors);
- if (bank->sectors == NULL) {
+ if (!bank->sectors) {
LOG_ERROR("failed to allocate bank sectors");
return ERROR_FAIL;
}
if (rev_id == info->revs[i].rev)
rev_str = info->revs[i].str;
- if (rev_str != NULL) {
+ if (rev_str) {
command_print_sameline(cmd, "%s - Rev: %s", info->device_str, rev_str);
} else {
command_print_sameline(cmd, "%s - Rev: unknown (0x%04x)", info->device_str, rev_id);
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[6], io_base);
stmqspi_info = malloc(sizeof(struct stmqspi_flash_bank));
- if (stmqspi_info == NULL) {
+ if (!stmqspi_info) {
LOG_ERROR("not enough memory");
return ERROR_FAIL;
}
bank->num_sectors =
stmqspi_info->dev.size_in_bytes / stmqspi_info->dev.sectorsize;
sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
- if (sectors == NULL) {
+ if (!sectors) {
LOG_ERROR("not enough memory");
return ERROR_FAIL;
}
/* create and fill sectors array */
bank->num_sectors = stmqspi_info->dev.size_in_bytes / stmqspi_info->dev.sectorsize;
sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
- if (sectors == NULL) {
+ if (!sectors) {
LOG_ERROR("not enough memory");
retval = ERROR_FAIL;
goto err;
return ERROR_COMMAND_SYNTAX_ERROR;
stmsmi_info = malloc(sizeof(struct stmsmi_flash_bank));
- if (stmsmi_info == NULL) {
+ if (!stmsmi_info) {
LOG_ERROR("not enough memory");
return ERROR_FAIL;
}
bank->num_sectors =
stmsmi_info->dev->size_in_bytes / sectorsize;
sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
- if (sectors == NULL) {
+ if (!sectors) {
LOG_ERROR("not enough memory");
return ERROR_FAIL;
}
static int str9xpec_set_instr(struct jtag_tap *tap, uint32_t new_instr, tap_state_t end_state)
{
- if (tap == NULL)
+ if (!tap)
return ERROR_TARGET_INVALID;
if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != new_instr) {
/* remove arm core from chain - enter turbo mode */
tap0 = str9xpec_info->tap;
- if (tap0 == NULL) {
+ if (!tap0) {
/* things are *WRONG* */
command_print(CMD, "**STR9FLASH** (tap0) invalid chain?");
return ERROR_FAIL;
}
tap1 = tap0->next_tap;
- if (tap1 == NULL) {
+ if (!tap1) {
/* things are *WRONG* */
command_print(CMD, "**STR9FLASH** (tap1) invalid chain?");
return ERROR_FAIL;
}
tap2 = tap1->next_tap;
- if (tap2 == NULL) {
+ if (!tap2) {
/* things are *WRONG* */
command_print(CMD, "**STR9FLASH** (tap2) invalid chain?");
return ERROR_FAIL;
str9xpec_info = bank->driver_priv;
tap = str9xpec_info->tap;
- if (tap == NULL)
+ if (!tap)
return ERROR_FAIL;
/* exit turbo mode via RESET */
if (retval != ERROR_OK)
return retval;
- if (p != NULL) {
+ if (p) {
int num_blocks;
struct flash_sector *block_array;
uint32_t padding_at_end = aligned_end - end_addr;
uint8_t *buffer = malloc(aligned_size);
- if (buffer == NULL)
+ if (!buffer)
return ERROR_FAIL;
if (padding_at_start) {
}
uint8_t *buffer = calloc(count, wordsize);
- if (buffer == NULL) {
+ if (!buffer) {
command_print(CMD, "No memory for flash read buffer");
return ERROR_FAIL;
}
uint32_t padding_at_end = aligned_end - end_addr;
buffer = malloc(aligned_size);
- if (buffer == NULL) {
+ if (!buffer) {
fileio_close(fileio);
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
buffer = malloc(length);
- if (buffer == NULL) {
+ if (!buffer) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
"first %zu bytes of the file", length);
buffer_file = malloc(length);
- if (buffer_file == NULL) {
+ if (!buffer_file) {
LOG_ERROR("Out of memory");
fileio_close(fileio);
return ERROR_FAIL;
}
buffer_flash = malloc(length);
- if (buffer_flash == NULL) {
+ if (!buffer_flash) {
LOG_ERROR("Out of memory");
free(buffer_file);
return ERROR_FAIL;
CMD_ARGC--;
struct target *target = get_target(CMD_ARGV[5]);
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("target '%s' not defined", CMD_ARGV[5]);
return ERROR_FAIL;
}
const char *driver_name = CMD_ARGV[0];
const struct flash_driver *driver = flash_driver_find_by_name(driver_name);
- if (NULL == driver) {
+ if (!driver) {
/* no matching flash driver found */
LOG_ERROR("flash driver '%s' not found", driver_name);
return ERROR_FAIL;
}
/* register flash specific commands */
- if (NULL != driver->commands) {
+ if (driver->commands) {
int retval = register_commands(CMD_CTX, NULL,
driver->commands);
if (retval != ERROR_OK) {
return retval;
}
- if (driver->usage == NULL)
+ if (!driver->usage)
LOG_DEBUG("'%s' driver usage field missing", driver_name);
flash_bank_add(c);
struct flash_bank *master_bank;
master_bank = get_flash_bank_by_name_noprobe(bank->driver_priv);
- if (master_bank == NULL)
+ if (!master_bank)
LOG_ERROR("master flash bank '%s' does not exist", (char *)bank->driver_priv);
return master_bank;
{
struct flash_bank *master_bank = virtual_get_master_bank(bank);
- if (master_bank == NULL)
+ if (!master_bank)
return;
/* update the info we do not have */
const char *bank_name = CMD_ARGV[6];
struct flash_bank *master_bank = get_flash_bank_by_name_noprobe(bank_name);
- if (master_bank == NULL) {
+ if (!master_bank) {
LOG_ERROR("master flash bank '%s' does not exist", bank_name);
return ERROR_FLASH_OPERATION_FAILED;
}
{
struct flash_bank *master_bank = virtual_get_master_bank(bank);
- if (master_bank == NULL)
+ if (!master_bank)
return ERROR_FLASH_OPERATION_FAILED;
return flash_driver_protect(master_bank, set, first, last);
{
struct flash_bank *master_bank = virtual_get_master_bank(bank);
- if (master_bank == NULL)
+ if (!master_bank)
return ERROR_FLASH_OPERATION_FAILED;
if (master_bank->driver->protect_check == NULL)
struct flash_bank *master_bank = virtual_get_master_bank(bank);
int retval;
- if (master_bank == NULL)
+ if (!master_bank)
return ERROR_FLASH_OPERATION_FAILED;
/* call master handler */
struct flash_bank *master_bank = virtual_get_master_bank(bank);
int retval;
- if (master_bank == NULL)
+ if (!master_bank)
return ERROR_FLASH_OPERATION_FAILED;
/* call master handler */
struct flash_bank *master_bank = virtual_get_master_bank(bank);
int retval;
- if (master_bank == NULL)
+ if (!master_bank)
return ERROR_FLASH_OPERATION_FAILED;
/* call master handler */
struct flash_bank *master_bank = virtual_get_master_bank(bank);
int retval;
- if (master_bank == NULL)
+ if (!master_bank)
return ERROR_FLASH_OPERATION_FAILED;
/* call master handler */
{
struct flash_bank *master_bank = virtual_get_master_bank(bank);
- if (master_bank == NULL)
+ if (!master_bank)
return ERROR_FLASH_OPERATION_FAILED;
command_print_sameline(cmd, "%s driver for flash bank %s at " TARGET_ADDR_FMT,
struct flash_bank *master_bank = virtual_get_master_bank(bank);
int retval;
- if (master_bank == NULL)
+ if (!master_bank)
return ERROR_FLASH_OPERATION_FAILED;
/* call master handler */
struct flash_bank *master_bank = virtual_get_master_bank(bank);
int retval;
- if (master_bank == NULL)
+ if (!master_bank)
return ERROR_FLASH_OPERATION_FAILED;
/* call master handler */
struct xcf_priv *priv;
priv = malloc(sizeof(struct xcf_priv));
- if (priv == NULL) {
+ if (!priv) {
LOG_ERROR("no memory for flash bank info");
return ERROR_FAIL;
}
}
bank->sectors = malloc(bank->num_sectors * sizeof(struct flash_sector));
- if (bank->sectors == NULL) {
+ if (!bank->sectors) {
LOG_ERROR("No memory for sector table");
return ERROR_FAIL;
}
}
}
- if (rev_str != NULL)
+ if (rev_str)
command_print_sameline(cmd, "%s - Rev: %s%s", dev_str, rev_str, prot_str);
else
command_print_sameline(cmd, "%s - Rev: unknown (0x%01x)%s", dev_str, rev_id, prot_str);
*/
static void command_log_capture_finish(struct log_capture_state *state)
{
- if (NULL == state)
+ if (!state)
return;
log_remove_callback(tcl_output, state);
static int command_retval_set(Jim_Interp *interp, int retval)
{
int *return_retval = Jim_GetAssocData(interp, "retval");
- if (return_retval != NULL)
+ if (return_retval)
*return_retval = retval;
return (retval == ERROR_OK) ? JIM_OK : retval;
unsigned argc, Jim_Obj * const *argv, unsigned *nwords)
{
char **words = malloc(argc * sizeof(char *));
- if (NULL == words)
+ if (!words)
return NULL;
unsigned i;
{
/* grab the command context from the associated data */
struct command_context *cmd_ctx = Jim_GetAssocData(interp, "context");
- if (NULL == cmd_ctx) {
+ if (!cmd_ctx) {
/* Tcl can invoke commands directly instead of via command_run_line(). This would
* happen when the Jim Tcl interpreter is provided by eCos or if we are running
* commands in a startup script.
full_name);
struct command *c = calloc(1, sizeof(struct command));
- if (NULL == c)
+ if (!c)
return NULL;
c->name = strdup(cr->name);
const struct command_registration *cr = cmds + i;
struct command *c = NULL;
- if (NULL != cr->name) {
+ if (cr->name) {
c = register_command(cmd_ctx, cmd_prefix, cr);
- if (NULL == c) {
+ if (!c) {
retval = ERROR_FAIL;
break;
}
c->jim_handler_data = data;
c->jim_override_target = override_target;
}
- if (NULL != cr->chain) {
+ if (cr->chain) {
if (cr->name) {
if (cmd_prefix) {
char *new_prefix = alloc_printf("%s %s", cmd_prefix, cr->name);
va_list ap;
va_start(ap, format);
string = alloc_vprintf(format, ap);
- if (string != NULL) {
+ if (string) {
retval = command_run_line(context, string);
free(string);
}
void command_done(struct command_context *cmd_ctx)
{
- if (NULL == cmd_ctx)
+ if (!cmd_ctx)
return;
free(cmd_ctx);
return JIM_ERR;
const char *file = Jim_GetString(argv[1], NULL);
char *full_path = find_file(file);
- if (full_path == NULL)
+ if (!full_path)
return JIM_ERR;
Jim_Obj *result = Jim_NewStringObj(interp, full_path, strlen(full_path));
free(full_path);
/* If the match string occurs anywhere, we print out
* stuff for this command. */
bool is_match = (strstr(c->cmd_name, cmd_match) != NULL) ||
- ((c->usage != NULL) && (strstr(c->usage, cmd_match) != NULL)) ||
- ((c->help != NULL) && (strstr(c->help, cmd_match) != NULL));
+ ((c->usage) && (strstr(c->usage, cmd_match) != NULL)) ||
+ ((c->help) && (strstr(c->help, cmd_match) != NULL));
if (is_match) {
if (c->usage && strlen(c->usage) > 0) {
} else
msg = alloc_printf("%s", c->help ? c->help : "");
- if (NULL != msg) {
+ if (msg) {
command_help_show_wrap(msg, n + 3, n + 3);
free(msg);
} else
}
}
- if (cmd_match == NULL) {
+ if (!cmd_match) {
LOG_ERROR("unable to build search string");
return -ENOMEM;
}
INIT_LIST_HEAD(context->help_list);
/* Create a jim interpreter if we were not handed one */
- if (interp == NULL) {
+ if (!interp) {
/* Create an interpreter */
interp = Jim_CreateInterp();
/* Add all the Jim core commands */
return fopen(file, mode);
else {
char *full_path = find_file(file);
- if (full_path == NULL)
+ if (!full_path)
return NULL;
FILE *fp = NULL;
fp = fopen(full_path, mode);
{
char *home = getenv("HOME");
- if (home == NULL) {
+ if (!home) {
#ifdef _WIN32
home = getenv("USERPROFILE");
- if (home == NULL) {
+ if (!home) {
char homepath[MAX_PATH];
char *drive = getenv("HOMEDRIVE");
#endif
}
- if (home == NULL)
+ if (!home)
return home;
char *home_path;
}
if (puthere)
*puthere = o;
- if (o != NULL)
+ if (o)
return JIM_OK;
else
return JIM_ERR;
Jim_Obj *o;
double _safe;
- if (puthere == NULL)
+ if (!puthere)
puthere = &_safe;
r = jim_getopt_obj(goi, &o);
Jim_Obj *o;
jim_wide _safe;
- if (puthere == NULL)
+ if (!puthere)
puthere = &_safe;
r = jim_getopt_obj(goi, &o);
Jim_Obj *o;
int e;
- if (puthere == NULL)
+ if (!puthere)
puthere = &_safe;
e = jim_getopt_obj(goi, &o);
Jim_Obj *o;
int e;
- if (puthere == NULL)
+ if (!puthere)
puthere = &_safe;
e = jim_getopt_obj(goi, &o);
if (e == JIM_OK)
}
f = strrchr(file, '/');
- if (f != NULL)
+ if (f)
file = f + 1;
if (strlen(string) > 0) {
va_start(ap, format);
string = alloc_vprintf(format, ap);
- if (string != NULL) {
+ if (string) {
log_puts(level, file, line, function, string);
free(string);
}
}
if (CMD_ARGC == 1) {
FILE *file = fopen(CMD_ARGV[0], "w");
- if (file == NULL) {
+ if (!file) {
LOG_ERROR("failed to open output log '%s'", CMD_ARGV[0]);
return ERROR_FAIL;
}
/* set defaults for daemon configuration,
* if not set by cmdline or cfgfile */
char *debug_env = getenv("OPENOCD_DEBUG_LEVEL");
- if (NULL != debug_env) {
+ if (debug_env) {
int value;
int retval = parse_int(debug_env, &value);
if (retval == ERROR_OK &&
debug_level = value;
}
- if (log_output == NULL)
+ if (!log_output)
log_output = stderr;
start = last_time = timeval_ms();
/* alloc memory, it is safe just to return in case of an error, no need for the caller to
*check this */
cb = malloc(sizeof(struct log_callback));
- if (cb == NULL)
+ if (!cb)
return ERROR_BUF_TOO_SMALL;
/* add item to the beginning of the linked list */
* other code depend on that. They should be probably be fixed, but for
* now reserve the extra byte. */
string = malloc(len + 2);
- if (string == NULL)
+ if (!string)
return NULL;
/* do the real work */
do {
#if IS_WIN32 && !IS_CYGWIN
exepath = malloc(MAX_PATH);
- if (exepath == NULL)
+ if (!exepath)
break;
GetModuleFileName(NULL, exepath, MAX_PATH);
#elif IS_DARWIN
exepath = malloc(PROC_PIDPATHINFO_MAXSIZE);
- if (exepath == NULL)
+ if (!exepath)
break;
if (proc_pidpath(getpid(), exepath, PROC_PIDPATHINFO_MAXSIZE) <= 0) {
free(exepath);
#define PATH_MAX 1024
#endif
char *path = malloc(PATH_MAX);
- if (path == NULL)
+ if (!path)
break;
int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
size_t size = PATH_MAX;
#elif defined(HAVE_REALPATH) /* Assume POSIX.1-2008 */
/* Try Unices in order of likelihood. */
exepath = realpath("/proc/self/exe", NULL); /* Linux/Cygwin */
- if (exepath == NULL)
+ if (!exepath)
exepath = realpath("/proc/self/path/a.out", NULL); /* Solaris */
- if (exepath == NULL)
+ if (!exepath)
exepath = realpath("/proc/curproc/file", NULL); /* FreeBSD (Should be covered above) */
#endif
} while (0);
- if (exepath != NULL) {
+ if (exepath) {
/* Strip executable file name, leaving path */
*strrchr(exepath, '/') = '\0';
} else {
if (from[0] != '/')
i++;
char *next = strchr(from, '/');
- if (next == NULL)
+ if (!next)
break;
from = next + 1;
}
void *clear_malloc(size_t size)
{
void *t = malloc(size);
- if (t != NULL)
+ if (t)
memset(t, 0x00, size);
return t;
}
void *fill_malloc(size_t size)
{
void *t = malloc(size);
- if (t != NULL) {
+ if (t) {
/* We want to initialize memory to some known bad state.
* 0 and 0xff yields 0 and -1 as integers, which often
* have meaningful values. 0x5555... is not often a valid
size_t len = strnlen(s, n);
char *new = malloc(len + 1);
- if (new == NULL)
+ if (!new)
return NULL;
new[len] = '\0';
#define SAFE_FD_ISSET(fd, set) (set != NULL && FD_ISSET(fd, set))
/* calculate how long we need to wait in milliseconds */
- if (tv == NULL)
+ if (!tv)
ms_total = INFINITE;
else {
ms_total = tv->tv_sec * 1000;
unsigned expected_len = sizeof(uint32_t) * tap->expected_ids_cnt;
uint32_t *new_expected_ids = malloc(expected_len + sizeof(uint32_t));
- if (new_expected_ids == NULL) {
+ if (!new_expected_ids) {
Jim_SetResultFormatted(goi->interp, "no memory");
return JIM_ERR;
}
bool set_op;
script_fd = fopen(script, "r");
- if (script_fd == NULL) {
+ if (!script_fd) {
return ERROR_FAIL;
} else {
while (fgets(line_buffer, LINE_BUFFER_SIZE, script_fd) != NULL) {
/* execute operations */
set_op = false;
op_str = strstr(line_buffer, "set");
- if (op_str != NULL) {
+ if (op_str) {
set_op = true;
goto get_reset_type;
}
op_str = strstr(line_buffer, "clear");
- if (op_str == NULL)
+ if (!op_str)
continue;
get_reset_type:
reset_str = strstr(op_str, "srst");
- if (reset_str != NULL) {
+ if (reset_str) {
if (set_op)
write_ctrl_value = AICE_CUSTOM_DELAY_SET_SRST;
else
goto get_delay;
}
reset_str = strstr(op_str, "dbgi");
- if (reset_str != NULL) {
+ if (reset_str) {
if (set_op)
write_ctrl_value = AICE_CUSTOM_DELAY_SET_DBGI;
else
goto get_delay;
}
reset_str = strstr(op_str, "trst");
- if (reset_str != NULL) {
+ if (reset_str) {
if (set_op)
write_ctrl_value = AICE_CUSTOM_DELAY_SET_TRST;
else
return ERROR_FAIL;
/* issue TRST */
- if (custom_trst_script == NULL) {
+ if (!custom_trst_script) {
if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL,
AICE_JTAG_PIN_CONTROL_TRST) != ERROR_OK)
return ERROR_FAIL;
/* After issuing srst, target will be running. So we need to restore EDM_CTL. */
aice_restore_edm_registers(coreid);
- if (custom_srst_script == NULL) {
+ if (!custom_srst_script) {
if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL,
AICE_JTAG_PIN_CONTROL_SRST) != ERROR_OK)
return ERROR_FAIL;
aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_STATUS, pin_status & (~0x4));
/* issue restart */
- if (custom_restart_script == NULL) {
+ if (!custom_restart_script) {
if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL,
AICE_JTAG_PIN_CONTROL_RESTART) != ERROR_OK)
return ERROR_FAIL;
aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_STATUS, pin_status | 0x4);
/* issue restart again */
- if (custom_restart_script == NULL) {
+ if (!custom_restart_script) {
if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL,
AICE_JTAG_PIN_CONTROL_RESTART) != ERROR_OK)
return ERROR_FAIL;
/* init strtok() */
command_str = strtok(command_sequence, ";");
- if (command_str == NULL)
+ if (!command_str)
return ERROR_OK;
do {
reg_name_0 = strstr(command_str, "gen_port0");
reg_name_1 = strstr(command_str, "gen_port1");
- if (reg_name_0 != NULL) {
+ if (reg_name_0) {
data_value = strtoul(reg_name_0 + 9, NULL, 0);
if (aice_write_misc(coreid,
NDS_EDM_MISC_GEN_PORT0, data_value) != ERROR_OK)
return ERROR_FAIL;
- } else if (reg_name_1 != NULL) {
+ } else if (reg_name_1) {
data_value = strtoul(reg_name_1 + 9, NULL, 0);
if (aice_write_misc(coreid,
/* update command_str */
command_str = strtok(NULL, ";");
- } while (command_str != NULL);
+ } while (command_str);
return ERROR_OK;
}
cmd->next = NULL;
struct jtag_command **last_cmd = next_command_pointer;
- assert(NULL != last_cmd);
+ assert(last_cmd);
assert(NULL == *last_cmd);
*last_cmd = cmd;
const char *jtag_tap_name(const struct jtag_tap *tap)
{
- return (tap == NULL) ? "(unknown)" : tap->dotted_name;
+ return (!tap) ? "(unknown)" : tap->dotted_name;
}
{
struct jtag_event_callback **callbacks_p = &jtag_event_callbacks;
- if (callback == NULL)
+ if (!callback)
return ERROR_COMMAND_SYNTAX_ERROR;
if (*callbacks_p) {
{
struct jtag_event_callback **p = &jtag_event_callbacks, *temp;
- if (callback == NULL)
+ if (!callback)
return ERROR_COMMAND_SYNTAX_ERROR;
while (*p) {
void jtag_add_plain_ir_scan(int num_bits, const uint8_t *out_bits, uint8_t *in_bits,
tap_state_t state)
{
- assert(out_bits != NULL);
+ assert(out_bits);
assert(state != TAP_RESET);
jtag_prelude(state);
void jtag_add_plain_dr_scan(int num_bits, const uint8_t *out_bits, uint8_t *in_bits,
tap_state_t state)
{
- assert(out_bits != NULL);
+ assert(out_bits);
assert(state != TAP_RESET);
jtag_prelude(state);
void jtag_check_value_mask(struct scan_field *field, uint8_t *value, uint8_t *mask)
{
- assert(field->in_value != NULL);
+ assert(field->in_value);
- if (value == NULL) {
+ if (!value) {
/* no checking to do */
return;
}
int default_interface_jtag_execute_queue(void)
{
- if (NULL == jtag) {
+ if (!jtag) {
LOG_ERROR("No JTAG interface configured yet. "
"Issue 'init' command in startup scripts "
"before communicating with targets.");
max_taps++;
uint8_t *idcode_buffer = calloc(4, max_taps);
- if (idcode_buffer == NULL)
+ if (!idcode_buffer)
return ERROR_JTAG_INIT_FAILED;
/* DR scan to collect BYPASS or IDCODE register contents.
uint32_t idcode = buf_get_u32(idcode_buffer, bit_count, 32);
/* No predefined TAP? Auto-probe. */
- if (tap == NULL) {
+ if (!tap) {
/* Is there another TAP? */
if (jtag_idcode_is_final(idcode))
break;
total_ir_length += 2;
ir_test = malloc(DIV_ROUND_UP(total_ir_length, 8));
- if (ir_test == NULL)
+ if (!ir_test)
return ERROR_FAIL;
/* after this scan, all TAPs will capture BYPASS instructions */
for (;; ) {
tap = jtag_tap_next_enabled(tap);
- if (tap == NULL)
+ if (!tap)
break;
/* If we're autoprobing, guess IR lengths. They must be at
return retval;
jtag = adapter_driver;
- if (jtag->speed == NULL) {
+ if (!jtag->speed) {
LOG_INFO("This adapter doesn't support configurable speed");
return ERROR_OK;
}
LOG_DEBUG("Init JTAG chain");
tap = jtag_tap_next_enabled(NULL);
- if (tap == NULL) {
+ if (!tap) {
/* Once JTAG itself is properly set up, and the scan chain
* isn't absurdly large, IDCODE autoprobe should work fine.
*
int jtag_power_dropout(int *dropout)
{
- if (jtag == NULL) {
+ if (!jtag) {
/* TODO: as the jtag interface is not valid all
* we can do at the moment is exit OpenOCD */
LOG_ERROR("No Valid JTAG Interface Configured.");
enum scan_type type;
uint8_t *buffer;
- while (cmd != NULL) {
+ while (cmd) {
switch (cmd->type) {
case JTAG_RUNTEST:
LOG_DEBUG_IO("runtest %i cycles, end in %i",
else
tdo_req = 0;
- if (field->out_value == NULL) {
+ if (!field->out_value) {
/* just send zeros and request data from TDO */
for (bit_cnt = field->num_bits; bit_cnt > 1; bit_cnt--)
bitq_io(0, 0, tdo_req);
static int buspirate_init(void)
{
- if (buspirate_port == NULL) {
+ if (!buspirate_port) {
LOG_ERROR("You need to specify the serial port!");
return ERROR_JTAG_INIT_FAILED;
}
if (CMD_ARGC < 1)
return ERROR_COMMAND_SYNTAX_ERROR;
- if (buspirate_port == NULL)
+ if (!buspirate_port)
buspirate_port = strdup(CMD_ARGV[0]);
return ERROR_OK;
const struct cmsis_dap_backend *backend = NULL;
struct cmsis_dap *dap = calloc(1, sizeof(struct cmsis_dap));
- if (dap == NULL) {
+ if (!dap) {
LOG_ERROR("unable to allocate memory");
return ERROR_FAIL;
}
}
}
- if (backend == NULL) {
+ if (!backend) {
LOG_ERROR("unable to find a matching CMSIS-DAP device");
free(dap);
return ERROR_FAIL;
(tdo_buffer != NULL ? DAP_JTAG_SEQ_TDO : 0) |
(s_len == 64 ? 0 : s_len);
- if (sequence != NULL)
+ if (sequence)
bit_copy(&queued_seq_buf[queued_seq_buf_end + 1], 0, sequence, s_offset, s_len);
else
memset(&queued_seq_buf[queued_seq_buf_end + 1], 0, DIV_ROUND_UP(s_len, 8));
queued_seq_buf_end += cmd_len;
- if (tdo_buffer != NULL) {
+ if (tdo_buffer) {
struct pending_scan_result *scan = &pending_scan_results[pending_scan_result_count++];
scan->first = queued_seq_tdo_ptr;
queued_seq_tdo_ptr += DIV_ROUND_UP(s_len, 8);
{
struct jtag_command *cmd = jtag_command_queue;
- while (cmd != NULL) {
+ while (cmd) {
cmsis_dap_execute_command(cmd);
cmd = cmd->next;
}
LOG_WARNING("could not claim interface: %s", libusb_strerror(err));
dap->bdata = malloc(sizeof(struct cmsis_dap_backend_data));
- if (dap->bdata == NULL) {
+ if (!dap->bdata) {
LOG_ERROR("unable to allocate memory");
libusb_release_interface(dev_handle, interface_num);
libusb_close(dev_handle);
dap->bdata->interface = interface_num;
dap->packet_buffer = malloc(dap->packet_buffer_size);
- if (dap->packet_buffer == NULL) {
+ if (!dap->packet_buffer) {
LOG_ERROR("unable to allocate memory");
cmsis_dap_usb_close(dap);
return ERROR_FAIL;
static int cmsis_dap_usb_alloc(struct cmsis_dap *dap, unsigned int pkt_sz)
{
uint8_t *buf = malloc(pkt_sz);
- if (buf == NULL) {
+ if (!buf) {
LOG_ERROR("unable to allocate CMSIS-DAP packet buffer");
return ERROR_FAIL;
}
*/
devs = hid_enumerate(0x0, 0x0);
cur_dev = devs;
- while (NULL != cur_dev) {
+ while (cur_dev) {
bool found = false;
if (0 == vids[0]) {
- if (NULL == cur_dev->product_string) {
+ if (!cur_dev->product_string) {
LOG_DEBUG("Cannot read product string of device 0x%x:0x%x",
cur_dev->vendor_id, cur_dev->product_id);
} else if (wcsstr(cur_dev->product_string, L"CMSIS-DAP")) {
if (found) {
/* check serial number matches if given */
- if (serial == NULL)
+ if (!serial)
break;
- if (cur_dev->serial_number != NULL) {
+ if (cur_dev->serial_number) {
size_t len = (strlen(serial) + 1) * sizeof(wchar_t);
wchar_t *wserial = malloc(len);
mbstowcs(wserial, serial, len);
cur_dev = cur_dev->next;
}
- if (NULL != cur_dev) {
+ if (cur_dev) {
target_vid = cur_dev->vendor_id;
target_pid = cur_dev->product_id;
}
}
dap->bdata = malloc(sizeof(struct cmsis_dap_backend_data));
- if (dap->bdata == NULL) {
+ if (!dap->bdata) {
LOG_ERROR("unable to allocate memory");
return ERROR_FAIL;
}
dev = hid_open_path(cur_dev->path);
hid_free_enumeration(devs);
- if (dev == NULL) {
+ if (!dev) {
LOG_ERROR("unable to open CMSIS-DAP device 0x%x:0x%x", target_vid, target_pid);
return ERROR_FAIL;
}
{
unsigned int packet_buffer_size = pkt_sz + REPORT_ID_SIZE;
uint8_t *buf = malloc(packet_buffer_size);
- if (buf == NULL) {
+ if (!buf) {
LOG_ERROR("unable to allocate CMSIS-DAP packet buffer");
return ERROR_FAIL;
}
struct jtag_command *cmd;
cmd = cmd_queue_alloc(sizeof(struct jtag_command));
- if (cmd == NULL)
+ if (!cmd)
return ERROR_FAIL;
cmd->type = JTAG_TMS;
entry->data2 = data2;
entry->data3 = data3;
- if (jtag_callback_queue_head == NULL) {
+ if (!jtag_callback_queue_head) {
jtag_callback_queue_head = entry;
jtag_callback_queue_tail = entry;
} else {
if (new_buf_size >= ft232r_buf_size) {
new_buf_size += FT232R_BUF_SIZE_EXTRA;
new_buf_ptr = realloc(ft232r_output, new_buf_size);
- if (new_buf_ptr != NULL) {
+ if (new_buf_ptr) {
ft232r_output = new_buf_ptr;
ft232r_buf_size = new_buf_size;
}
uint16_t apids[] = {ft232r_pid, 0};
if (jtag_libusb_open(avids, apids, ft232r_serial_desc, &adapter, NULL)) {
LOG_ERROR("ft232r not found: vid=%04x, pid=%04x, serial=%s\n",
- ft232r_vid, ft232r_pid, (ft232r_serial_desc == NULL) ? "[any]" : ft232r_serial_desc);
+ ft232r_vid, ft232r_pid, (!ft232r_serial_desc) ? "[any]" : ft232r_serial_desc);
return ERROR_JTAG_INIT_FAILED;
}
}
ft232r_output = malloc(ft232r_buf_size);
- if (ft232r_output == NULL) {
+ if (!ft232r_output) {
LOG_ERROR("Unable to allocate memory for the buffer");
return ERROR_JTAG_INIT_FAILED;
}
if (CMD_ARGC > 0) {
n = jim_nvp_name2value_simple(nvp_ftdi_jtag_modes, CMD_ARGV[0]);
- if (n->name == NULL)
+ if (!n->name)
return ERROR_COMMAND_SYNTAX_ERROR;
ftdi_jtag_mode = n->value;
* pointers into the queue which may be invalid after the realloc. */
queued_retval = ftdi_swd_run_queue();
struct swd_cmd_queue_entry *q = realloc(swd_cmd_queue, swd_cmd_queue_alloced * 2 * sizeof(*swd_cmd_queue));
- if (q != NULL) {
+ if (q) {
swd_cmd_queue = q;
swd_cmd_queue_alloced *= 2;
LOG_DEBUG("Increased SWD command queue to %zu elements", swd_cmd_queue_alloced);
int ret;
struct jtag_command *cmd = jtag_command_queue;
- while (cmd != NULL) {
+ while (cmd) {
ret = jlink_execute_command(cmd);
if (ret != ERROR_OK)
static int write_sock(char *buf, size_t len)
{
- if (buf == NULL) {
+ if (!buf) {
LOG_ERROR("%s: NULL 'buf' argument, file %s, line %d",
__func__, __FILE__, __LINE__);
return ERROR_FAIL;
static int read_sock(char *buf, size_t len)
{
- if (buf == NULL) {
+ if (!buf) {
LOG_ERROR("%s: NULL 'buf' argument, file %s, line %d",
__func__, __FILE__, __LINE__);
return ERROR_FAIL;
int ret = ERROR_OK;
num_bits = jtag_build_buffer(cmd, &data_buf);
- if (data_buf == NULL) {
+ if (!data_buf) {
LOG_ERROR("jtag_build_buffer call failed, data_buf == NULL, "
"file %s, line %d", __FILE__, __LINE__);
return ERROR_FAIL;
if (cmd->ir_scan) {
free(last_ir_buf);
last_ir_buf = (uint8_t *)malloc(bytes * sizeof(uint8_t));
- if (last_ir_buf == NULL) {
+ if (!last_ir_buf) {
LOG_ERROR("%s: malloc fail, file %s, line %d",
__func__, __FILE__, __LINE__);
ret = ERROR_FAIL;
int num_bits = last_ir_num_bits, bytes;
int ret = ERROR_OK;
- if (data_buf == NULL) {
+ if (!data_buf) {
LOG_ERROR("%s: NULL 'data_buf' argument, file %s, line %d",
__func__, __FILE__, __LINE__);
return ERROR_FAIL;
bytes = DIV_ROUND_UP(num_bits, 8);
read_scan = (uint8_t *)malloc(bytes * sizeof(uint8_t));
- if (read_scan == NULL) {
+ if (!read_scan) {
LOG_ERROR("%s: malloc fail, file %s, line %d",
__func__, __FILE__, __LINE__);
return ERROR_FAIL;
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(server_port);
- if (server_address == NULL) {
+ if (!server_address) {
server_address = strdup(SERVER_ADDRESS);
- if (server_address == NULL) {
+ if (!server_address) {
LOG_ERROR("%s: strdup fail, file %s, line %d",
__func__, __FILE__, __LINE__);
return ERROR_FAIL;
if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
else if (CMD_ARGC == 0) {
- if (server_address == NULL) {
+ if (!server_address) {
server_address = strdup(SERVER_ADDRESS);
- if (server_address == NULL) {
+ if (!server_address) {
LOG_ERROR("%s: strdup fail, file %s, line %d",
__func__, __FILE__, __LINE__);
return ERROR_FAIL;
} else {
free(server_address);
server_address = strdup(CMD_ARGV[0]);
- if (server_address == NULL) {
+ if (!server_address) {
LOG_ERROR("%s: strdup fail, file %s, line %d",
__func__, __FILE__, __LINE__);
return ERROR_FAIL;
string_length = strnlen(loc, JTAG_USB_MAX_LOCATION_LENGTH);
ptr = strtok(loc, "-");
- if (ptr == NULL) {
+ if (!ptr) {
LOG_WARNING("no '-' in usb path\n");
goto done;
}
ptr = strtok(NULL, ".");
/* no more tokens in path */
- if (ptr == NULL)
+ if (!ptr)
break;
/* path mismatch at some step */
int retval;
kitprog_handle = malloc(sizeof(struct kitprog));
- if (kitprog_handle == NULL) {
+ if (!kitprog_handle) {
LOG_ERROR("Failed to allocate memory");
return ERROR_FAIL;
}
/* Allocate packet buffers and queues */
kitprog_handle->packet_size = SWD_MAX_BUFFER_LENGTH;
kitprog_handle->packet_buffer = malloc(SWD_MAX_BUFFER_LENGTH);
- if (kitprog_handle->packet_buffer == NULL) {
+ if (!kitprog_handle->packet_buffer) {
LOG_ERROR("Failed to allocate memory for the packet buffer");
return ERROR_FAIL;
}
pending_queue_len = SWD_MAX_BUFFER_LENGTH / 5;
pending_transfers = malloc(pending_queue_len * sizeof(*pending_transfers));
- if (pending_transfers == NULL) {
+ if (!pending_transfers) {
LOG_ERROR("Failed to allocate memory for the SWD transfer queue");
return ERROR_FAIL;
}
/* Allocate memory for the serial number */
kitprog_handle->serial = calloc(retval + 1, sizeof(char));
- if (kitprog_handle->serial == NULL) {
+ if (!kitprog_handle->serial) {
LOG_ERROR("Failed to allocate memory for the serial number");
return ERROR_FAIL;
}
/* Convert the ASCII serial number into a (wchar_t *) */
size_t len = strlen(kitprog_handle->serial);
wchar_t *hid_serial = calloc(len + 1, sizeof(wchar_t));
- if (hid_serial == NULL) {
+ if (!hid_serial) {
LOG_ERROR("Failed to allocate memory for the serial number");
return ERROR_FAIL;
}
/* Use HID for the KitBridge interface */
kitprog_handle->hid_handle = hid_open(VID, PID, hid_serial);
free(hid_serial);
- if (kitprog_handle->hid_handle == NULL) {
+ if (!kitprog_handle->hid_handle) {
LOG_ERROR("Failed to open KitBridge (HID) interface");
return ERROR_FAIL;
}
static void kitprog_usb_close(void)
{
- if (kitprog_handle->hid_handle != NULL) {
+ if (kitprog_handle->hid_handle) {
hid_close(kitprog_handle->hid_handle);
hid_exit();
}
{
if (CMD_ARGC == 1) {
kitprog_serial = strdup(CMD_ARGV[0]);
- if (kitprog_serial == NULL) {
+ if (!kitprog_serial) {
LOG_ERROR("Failed to allocate memory for the serial number");
return ERROR_FAIL;
}
char *alternate_serial = adapter_get_alternate_serial(device, dev_desc);
/* check possible failures */
- if (alternate_serial == NULL)
+ if (!alternate_serial)
return false;
/* then compare and free the alternate serial */
LOG_DEBUG("linuxgpiod_reset");
/* assume active low */
- if (gpiod_srst != NULL) {
+ if (gpiod_srst) {
retval1 = gpiod_line_set_value(gpiod_srst, srst ? 0 : 1);
if (retval1 < 0)
LOG_WARNING("set srst value failed");
}
/* assume active low */
- if (gpiod_trst != NULL) {
+ if (gpiod_trst) {
retval2 = gpiod_line_set_value(gpiod_trst, trst ? 0 : 1);
if (retval2 < 0)
LOG_WARNING("set trst value failed");
int retval;
line = gpiod_chip_get_line(gpiod_chip, offset);
- if (line == NULL) {
+ if (!line) {
LOG_ERROR("Error get line %s", label);
return NULL;
}
int retval;
line = gpiod_chip_get_line(gpiod_chip, offset);
- if (line == NULL) {
+ if (!line) {
LOG_ERROR("Error get line %s", label);
return NULL;
}
bitbang_interface = &linuxgpiod_bitbang;
gpiod_chip = gpiod_chip_open_by_number(gpiochip);
- if (gpiod_chip == NULL) {
+ if (!gpiod_chip) {
LOG_ERROR("Cannot open LinuxGPIOD gpiochip %d", gpiochip);
return ERROR_JTAG_INIT_FAILED;
}
}
gpiod_tdo = helper_get_input_line("tdo", tdo_gpio);
- if (gpiod_tdo == NULL)
+ if (!gpiod_tdo)
goto out_error;
gpiod_tdi = helper_get_output_line("tdi", tdi_gpio, 0);
- if (gpiod_tdi == NULL)
+ if (!gpiod_tdi)
goto out_error;
gpiod_tck = helper_get_output_line("tck", tck_gpio, 0);
- if (gpiod_tck == NULL)
+ if (!gpiod_tck)
goto out_error;
gpiod_tms = helper_get_output_line("tms", tms_gpio, 1);
- if (gpiod_tms == NULL)
+ if (!gpiod_tms)
goto out_error;
if (is_gpio_valid(trst_gpio)) {
gpiod_trst = helper_get_output_line("trst", trst_gpio, 1);
- if (gpiod_trst == NULL)
+ if (!gpiod_trst)
goto out_error;
}
}
}
gpiod_swclk = helper_get_output_line("swclk", swclk_gpio, 1);
- if (gpiod_swclk == NULL)
+ if (!gpiod_swclk)
goto out_error;
gpiod_swdio = helper_get_output_line("swdio", swdio_gpio, 1);
- if (gpiod_swdio == NULL)
+ if (!gpiod_swdio)
goto out_error;
}
if (is_gpio_valid(srst_gpio)) {
gpiod_srst = helper_get_output_line("srst", srst_gpio, 1);
- if (gpiod_srst == NULL)
+ if (!gpiod_srst)
goto out_error;
}
if (is_gpio_valid(led_gpio)) {
gpiod_led = helper_get_output_line("led", led_gpio, 0);
- if (gpiod_led == NULL)
+ if (!gpiod_led)
goto out_error;
}
LOG_DEBUG("device path has %i steps", path_len);
ptr = strtok(loc, "-:");
- if (ptr == NULL) {
+ if (!ptr) {
LOG_DEBUG("no ':' in path");
goto done;
}
path_step = 0;
while (path_step < 7) {
ptr = strtok(NULL, ".,");
- if (ptr == NULL) {
+ if (!ptr) {
LOG_DEBUG("no more tokens in path at step %i", path_step);
break;
}
return ERROR_OK;
/* only if the cable name wasn't overwritten by cmdline */
- if (opendous_type == NULL) {
+ if (!opendous_type) {
/* REVISIT first verify that it's listed in cables[] ... */
opendous_type = strdup(CMD_ARGV[0]);
}
enum scan_type type;
uint8_t *buffer;
- while (cmd != NULL) {
+ while (cmd) {
switch (cmd->type) {
case JTAG_RUNTEST:
LOG_DEBUG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles,
cur_opendous_probe = opendous_probes;
- if (opendous_type == NULL) {
+ if (!opendous_type) {
opendous_type = strdup("opendous");
LOG_WARNING("No opendous_type specified, using default 'opendous'");
}
uint8_t latency_timer;
/* Open by device description */
- if (openjtag_device_desc == NULL) {
+ if (!openjtag_device_desc) {
LOG_WARNING("no openjtag device description specified, "
"using default 'Open JTAG Project'");
openjtag_device_desc = "Open JTAG Project";
return ERROR_OK;
err:
- if (usbh != NULL)
+ if (usbh)
jtag_libusb_close(usbh);
return ERROR_JTAG_INIT_FAILED;
}
{
struct jtag_command *cmd = jtag_command_queue;
- while (cmd != NULL) {
+ while (cmd) {
openjtag_execute_command(cmd);
cmd = cmd->next;
}
cur_cable = cables;
- if (parport_cable == NULL) {
+ if (!parport_cable) {
parport_cable = strdup("wiggler");
LOG_WARNING("No parport cable specified, using default 'wiggler'");
}
{
if (presto_open(presto_serial) != ERROR_OK) {
presto_close();
- if (presto_serial != NULL)
+ if (presto_serial)
LOG_ERROR("Cannot open PRESTO, serial number '%s'", presto_serial);
else
LOG_ERROR("Cannot open PRESTO");
freeaddrinfo(result); /* No longer needed */
- if (rp == NULL) { /* No address succeeded */
+ if (!rp) { /* No address succeeded */
log_socket_error("Failed to connect");
return ERROR_FAIL;
}
static int remote_bitbang_init_unix(void)
{
- if (remote_bitbang_host == NULL) {
+ if (!remote_bitbang_host) {
LOG_ERROR("host/socket not specified");
return ERROR_FAIL;
}
remote_bitbang_recv_buf_end = 0;
LOG_INFO("Initializing remote_bitbang driver");
- if (remote_bitbang_port == NULL)
+ if (!remote_bitbang_port)
remote_bitbang_fd = remote_bitbang_init_unix();
else
remote_bitbang_fd = remote_bitbang_init_tcp();
struct dtc_reply_queue_entry *rq_entry;
rq_entry = malloc(sizeof(struct dtc_reply_queue_entry));
- if (rq_entry != NULL) {
+ if (rq_entry) {
rq_entry->scan.type = type;
rq_entry->scan.buffer = buffer;
rq_entry->scan.size = size;
rq_entry->cmd = cmd;
rq_entry->next = NULL;
- if (dtc_queue.rq_head == NULL)
+ if (!dtc_queue.rq_head)
dtc_queue.rq_head = rq_entry;
else
dtc_queue.rq_tail->next = rq_entry;
exit(1);
}
- if (dtc_queue.rq_head != NULL) {
+ if (dtc_queue.rq_head) {
/* process the reply, which empties the reply queue and frees its entries */
dtc_p = reply_buffer;
{
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (h->version.flags & STLINK_F_HAS_RW8_512BYTES)
return STLINKV3_MAX_RW8;
struct stlink_usb_handle_s *h = handle;
int tr, ret;
- assert(handle != NULL);
+ assert(handle);
/* read status */
memset(h->cmdbuf, 0, STLINK_SG_SIZE);
{
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
size_t n_transfers = 0;
struct jtag_xfer transfers[2];
struct stlink_usb_handle_s *h = handle;
int tr, ret;
- assert(handle != NULL);
+ assert(handle);
ret = jtag_libusb_bulk_write(h->usb_backend_priv.fd, h->tx_ep, (char *)h->cmdbuf,
cmdsize, STLINK_WRITE_TIMEOUT, &tr);
int res;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
stlink_usb_init_buffer(handle, h->rx_ep, 16);
int err, cmdsize = STLINK_CMD_SIZE_V2;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (h->version.stlink == 1) {
cmdsize = STLINK_SG_SIZE;
{
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
/* send the TCP command */
int sent_size = send(h->tcp_backend_priv.fd, (void *)h->tcp_backend_priv.send_buf, send_size, 0);
int send_size = STLINK_TCP_USB_CMD_SIZE;
int recv_size = STLINK_TCP_SS_SIZE;
- assert(handle != NULL);
+ assert(handle);
/* prepare the TCP command */
h->tcp_backend_priv.send_buf[0] = STLINK_TCP_CMD_SEND_USB_CMD;
{
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (h->st_mode == STLINK_MODE_DEBUG_SWIM) {
switch (h->databuf[0]) {
{
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
assert(h->version.flags & STLINK_F_HAS_TRACE);
char *p;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
stlink_usb_init_buffer(handle, h->rx_ep, 6);
{
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (!(h->version.flags & STLINK_F_HAS_SWD_SET_FREQ))
return ERROR_COMMAND_NOTFOUND;
{
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (!(h->version.flags & STLINK_F_HAS_JTAG_SET_FREQ))
return ERROR_COMMAND_NOTFOUND;
int res;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
stlink_usb_init_buffer(handle, h->rx_ep, 2);
int rx_size = 0;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
/* on api V2 we are able the read the latest command
* status
int res;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
/* command with no reply, use a valid endpoint but zero size */
stlink_usb_init_buffer(handle, h->rx_ep, 0);
uint8_t mode;
enum stlink_mode emode;
- assert(handle != NULL);
+ assert(handle);
res = stlink_usb_current_mode(handle, &mode);
enum stlink_mode emode;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
res = stlink_usb_exit_mode(handle);
if (res != ERROR_OK)
int res, offset;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
/* there is no swim read core id cmd */
if (h->st_mode == STLINK_MODE_DEBUG_SWIM) {
struct stlink_usb_handle_s *h = handle;
int res;
- assert(handle != NULL);
+ assert(handle);
stlink_usb_init_buffer(handle, h->rx_ep, 8);
{
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
stlink_usb_init_buffer(handle, h->rx_ep, 2);
{
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (h->trace.enabled && (h->version.flags & STLINK_F_HAS_TRACE)) {
int res;
int res;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (h->reconnect_pending) {
LOG_INFO("Previous state query failed, trying to reconnect");
{
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (h->st_mode == STLINK_MODE_DEBUG_SWIM)
return stlink_swim_assert_reset(handle, srst);
int res = ERROR_OK;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
assert(h->version.flags & STLINK_F_HAS_TRACE);
int res;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (h->version.flags & STLINK_F_HAS_TRACE) {
stlink_usb_init_buffer(handle, h->rx_ep, 10);
struct stlink_usb_handle_s *h = handle;
int retval;
- assert(handle != NULL);
+ assert(handle);
stlink_usb_init_buffer(handle, h->rx_ep, 2);
int res;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (h->version.jtag_api != STLINK_JTAG_API_V1) {
res = stlink_usb_write_debug_reg(handle, DCB_DHCSR, DBGKEY|C_DEBUGEN);
int res;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (h->version.jtag_api != STLINK_JTAG_API_V1) {
res = stlink_usb_write_debug_reg(handle, DCB_DHCSR, DBGKEY|C_HALT|C_DEBUGEN);
{
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (h->version.jtag_api != STLINK_JTAG_API_V1) {
/* TODO: this emulates the v1 api, it should really use a similar auto mask isr
int res;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
stlink_usb_init_buffer(handle, h->rx_ep, 88);
int res;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (STLINK_REGSEL_IS_FPU(regsel) && !(h->version.flags & STLINK_F_HAS_FPU_REG)) {
res = stlink_usb_write_debug_reg(h, DCB_DCRSR, regsel & 0x7f);
{
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (STLINK_REGSEL_IS_FPU(regsel) && !(h->version.flags & STLINK_F_HAS_FPU_REG)) {
int res = stlink_usb_write_debug_reg(h, DCB_DCRDR, val);
{
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (h->version.jtag_api == STLINK_JTAG_API_V1)
return ERROR_OK;
uint16_t read_len = len;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
/* max 8 bit read/write is 64 bytes or 512 bytes for v3 */
if (len > stlink_usb_block(h)) {
int res;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
/* max 8 bit read/write is 64 bytes or 512 bytes for v3 */
if (len > stlink_usb_block(h)) {
int res;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (!(h->version.flags & STLINK_F_HAS_MEM_16BIT))
return ERROR_COMMAND_NOTFOUND;
int res;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (!(h->version.flags & STLINK_F_HAS_MEM_16BIT))
return ERROR_COMMAND_NOTFOUND;
int res;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
/* data must be a multiple of 4 and word aligned */
if (len % 4 || addr % 4) {
int res;
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
/* data must be a multiple of 4 and word aligned */
if (len % 4 || addr % 4) {
/** */
static int stlink_close(void *handle)
{
- if (handle != NULL) {
+ if (handle) {
struct stlink_usb_handle_s *h = handle;
stlink_usb_close(handle);
/* else (len == 26) => buggy ST-Link */
char *alternate_serial = malloc((STLINK_SERIAL_LEN + 1) * sizeof(char));
- if (alternate_serial == NULL)
+ if (!alternate_serial)
return NULL;
for (unsigned int i = 0; i < STLINK_SERIAL_LEN; i += 2)
char serial[STLINK_TCP_SERIAL_SIZE + 1] = {0};
uint8_t stlink_used;
bool stlink_id_matched = false;
- bool stlink_serial_matched = (param->serial == NULL);
+ bool stlink_serial_matched = (!param->serial);
for (uint32_t stlink_id = 0; stlink_id < connected_stlinks; stlink_id++) {
/* get the stlink info */
return ERROR_OK;
}
- assert(trace_freq != NULL);
- assert(prescaler != NULL);
+ assert(trace_freq);
+ assert(prescaler);
if (pin_protocol != TPIU_PIN_PROTOCOL_ASYNC_UART) {
LOG_ERROR("The attached ST-LINK version doesn't support this trace mode");
{
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (!(h->version.flags & STLINK_F_HAS_AP_INIT))
return ERROR_COMMAND_NOTFOUND;
{
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (!(h->version.flags & STLINK_F_HAS_AP_INIT))
return ERROR_COMMAND_NOTFOUND;
struct stlink_usb_handle_s *h = handle;
int retval;
- assert(handle != NULL);
+ assert(handle);
if (!(h->version.flags & STLINK_F_HAS_DAP_REG))
return ERROR_COMMAND_NOTFOUND;
{
struct stlink_usb_handle_s *h = handle;
- assert(handle != NULL);
+ assert(handle);
if (!(h->version.flags & STLINK_F_HAS_DAP_REG))
return ERROR_COMMAND_NOTFOUND;
int result, retry = 0;
int transferred = 0;
- assert(handle != NULL);
+ assert(handle);
/* check we have a large enough buffer for checksum "#00" */
if (len + 3 > h->max_packet) {
int offset = 0;
char ch;
- assert(handle != NULL);
+ assert(handle);
do {
ch = h->read_buffer[offset++];
payload = calloc(size, sizeof(uint8_t));
- if (payload == NULL) {
+ if (!payload) {
LOG_ERROR("Could not allocate OpenULINK command payload: out of memory");
return ERROR_FAIL;
}
switch (direction) {
case PAYLOAD_DIRECTION_OUT:
- if (ulink_cmd->payload_out != NULL) {
+ if (ulink_cmd->payload_out) {
LOG_ERROR("BUG: Duplicate payload allocation for OpenULINK command");
free(payload);
return ERROR_FAIL;
}
break;
case PAYLOAD_DIRECTION_IN:
- if (ulink_cmd->payload_in_start != NULL) {
+ if (ulink_cmd->payload_in_start) {
LOG_ERROR("BUG: Duplicate payload allocation for OpenULINK command");
free(payload);
return ERROR_FAIL;
struct ulink_cmd *current = device->queue_start;
int sum = 0;
- while (current != NULL) {
+ while (current) {
switch (direction) {
case PAYLOAD_DIRECTION_OUT:
sum += current->payload_out_size + 1; /* + 1 byte for Command ID */
struct ulink_cmd *current = device->queue_start;
struct ulink_cmd *next = NULL;
- while (current != NULL) {
+ while (current) {
/* Save pointer to next element */
next = current->next;
ulink_clear_queue(device);
}
- if (device->queue_start == NULL) {
+ if (!device->queue_start) {
/* Queue was empty */
device->commands_in_queue = 1;
int ret, i, scan_size_bytes;
uint8_t bits_last_byte;
- if (cmd == NULL)
+ if (!cmd)
return ERROR_FAIL;
/* Check size of command. USB buffer can hold 64 bytes, 1 byte is command ID,
struct ulink_cmd *cmd = calloc(1, sizeof(struct ulink_cmd));
int ret;
- if (cmd == NULL)
+ if (!cmd)
return ERROR_FAIL;
if (device->delay_clock_tms < 0)
struct ulink_cmd *cmd = calloc(1, sizeof(struct ulink_cmd));
int ret;
- if (cmd == NULL)
+ if (!cmd)
return ERROR_FAIL;
if (device->delay_clock_tck < 0)
struct ulink_cmd *cmd = calloc(1, sizeof(struct ulink_cmd));
int ret;
- if (cmd == NULL)
+ if (!cmd)
return ERROR_FAIL;
cmd->id = CMD_GET_SIGNALS;
struct ulink_cmd *cmd = calloc(1, sizeof(struct ulink_cmd));
int ret;
- if (cmd == NULL)
+ if (!cmd)
return ERROR_FAIL;
cmd->id = CMD_SET_SIGNALS;
struct ulink_cmd *cmd = calloc(1, sizeof(struct ulink_cmd));
int ret;
- if (cmd == NULL)
+ if (!cmd)
return ERROR_FAIL;
cmd->id = CMD_SLEEP_US;
struct ulink_cmd *cmd = calloc(1, sizeof(struct ulink_cmd));
int ret;
- if (cmd == NULL)
+ if (!cmd)
return ERROR_FAIL;
cmd->id = CMD_CONFIGURE_TCK_FREQ;
struct ulink_cmd *cmd = calloc(1, sizeof(struct ulink_cmd));
int ret;
- if (cmd == NULL)
+ if (!cmd)
return ERROR_FAIL;
cmd->id = CMD_SET_LEDS;
struct ulink_cmd *cmd = calloc(1, sizeof(struct ulink_cmd));
int ret;
- if (cmd == NULL)
+ if (!cmd)
return ERROR_FAIL;
cmd->id = CMD_TEST;
if ((type == SCAN_IN) || (type == SCAN_IO)) {
tdo_buffer_start = calloc(sizeof(uint8_t), scan_size_bytes);
- if (tdo_buffer_start == NULL)
+ if (!tdo_buffer_start)
return ERROR_FAIL;
tdo_buffer = tdo_buffer_start;
bytecount -= 58;
/* Update TDI and TDO buffer pointers */
- if (tdi_buffer_start != NULL)
+ if (tdi_buffer_start)
tdi_buffer += 58;
- if (tdo_buffer_start != NULL)
+ if (tdo_buffer_start)
tdo_buffer += 58;
} else if (bytecount == 58) { /* Full scan, no further scans */
tms_count_end = last_tms_count;
current = device->queue_start;
- while (current != NULL) {
+ while (current) {
openocd_cmd = current->cmd_origin;
/* Check if a corresponding OpenOCD command is stored for this
* OpenULINK command */
- if ((current->needs_postprocessing == true) && (openocd_cmd != NULL)) {
+ if ((current->needs_postprocessing == true) && (openocd_cmd)) {
switch (openocd_cmd->type) {
case JTAG_SCAN:
ret = ulink_post_process_scan(current);
uint8_t input_signals, output_signals;
ulink_handle = calloc(1, sizeof(struct ulink));
- if (ulink_handle == NULL)
+ if (!ulink_handle)
return ERROR_FAIL;
libusb_init(&ulink_handle->libusb_ctx);
{
struct versaloon_pending_t *pending = (struct versaloon_pending_t *)p;
- if (pending->extra_data != NULL)
+ if (pending->extra_data)
*((uint8_t *)pending->extra_data) = src[0];
return ERROR_OK;
{
struct versaloon_pending_t *pending = (struct versaloon_pending_t *)p;
- if (pending->extra_data != NULL)
+ if (pending->extra_data)
*((uint8_t *)pending->extra_data) = src[0];
/* mark it processed to ignore other input data */
parity += (request >> 4) & 1;
parity &= 1;
buff[0] = (request | 0x81 | (parity << 5)) & ~0x40;
- if (data != NULL)
+ if (data)
SET_LE_U32(&buff[1], *data);
else
memset(buff + 1, 0, 4);
{
if (type_pre > 0) {
/* not the first command */
- if (NULL == usbtoxxx_buffer) {
+ if (!usbtoxxx_buffer) {
LOG_BUG(ERRMSG_INVALID_BUFFER, TO_STR(usbtoxxx_buffer));
return ERRCODE_INVALID_BUFFER;
}
struct versaloon_want_pos_t *tmp;
tmp = versaloon_pending[i].pos;
- while (tmp != NULL) {
- if ((tmp->buff != NULL) && (tmp->size > 0)) {
+ while (tmp) {
+ if ((tmp->buff) && (tmp->size > 0)) {
memcpy(tmp->buff,
versaloon_buf + usbtoxxx_buffer_index
+ tmp->offset,
if (ERROR_OK != usbtoxxx_ensure_buffer_size(cmdlen + 6))
return ERROR_FAIL;
- if ((type_pre != type) || (NULL == usbtoxxx_buffer)) {
+ if ((type_pre != type) || (!usbtoxxx_buffer)) {
if (ERROR_OK != usbtoxxx_validate_current_command_type()) {
LOG_BUG(ERRMSG_FAILURE_OPERATION, "validate previous commands");
return ERRCODE_FAILURE_OPERATION;
SET_LE_U16(&usbtoxxx_buffer[collect_index], len_tmp);
}
- if (cmdbuf != NULL) {
+ if (cmdbuf) {
memcpy(usbtoxxx_buffer + usbtoxxx_current_cmd_index, cmdbuf, cmdlen);
usbtoxxx_current_cmd_index += cmdlen;
}
struct versaloon_want_pos_t *tmp, *free_tmp;
tmp = versaloon_want_pos;
- while (tmp != NULL) {
+ while (tmp) {
free_tmp = tmp;
tmp = tmp->next;
free(free_tmp);
for (i = 0; i < ARRAY_SIZE(versaloon_pending); i++) {
tmp = versaloon_pending[i].pos;
- while (tmp != NULL) {
+ while (tmp) {
free_tmp = tmp;
tmp = tmp->next;
free(free_tmp);
struct versaloon_want_pos_t *new_pos = NULL;
new_pos = malloc(sizeof(*new_pos));
- if (NULL == new_pos) {
+ if (!new_pos) {
LOG_ERROR(ERRMSG_NOT_ENOUGH_MEMORY);
return ERRCODE_NOT_ENOUGH_MEMORY;
}
new_pos->buff = buff;
new_pos->next = NULL;
- if (NULL == versaloon_want_pos)
+ if (!versaloon_want_pos)
versaloon_want_pos = new_pos;
else {
struct versaloon_want_pos_t *tmp = versaloon_want_pos;
- while (tmp->next != NULL)
+ while (tmp->next)
tmp = tmp->next;
tmp->next = new_pos;
}
int transferred;
#if PARAM_CHECK
- if (NULL == versaloon_buf) {
+ if (!versaloon_buf) {
LOG_BUG(ERRMSG_INVALID_BUFFER, TO_STR(versaloon_buf));
return ERRCODE_INVALID_BUFFER;
}
return ERRCODE_FAILURE_OPERATION;
}
- if (inlen != NULL) {
+ if (inlen) {
ret = libusb_bulk_transfer(versaloon_usb_device_handle,
versaloon_interface.usb_setting.ep_in,
versaloon_buf, versaloon_interface.usb_setting.buf_size,
/* malloc temporary buffer */
versaloon_buf = malloc(versaloon_interface.usb_setting.buf_size);
- if (NULL == versaloon_buf) {
+ if (!versaloon_buf) {
LOG_ERROR(ERRMSG_NOT_ENOUGH_MEMORY);
return ERRCODE_NOT_ENOUGH_MEMORY;
}
versaloon_buf = NULL;
versaloon_buf = malloc(versaloon_interface.usb_setting.buf_size);
- if (NULL == versaloon_buf) {
+ if (!versaloon_buf) {
versaloon_fini();
LOG_ERROR(ERRMSG_NOT_ENOUGH_MEMORY);
return ERRCODE_NOT_ENOUGH_MEMORY;
}
versaloon_cmd_buf = malloc(versaloon_interface.usb_setting.buf_size - 3);
- if (NULL == versaloon_cmd_buf) {
+ if (!versaloon_cmd_buf) {
versaloon_fini();
LOG_ERROR(ERRMSG_NOT_ENOUGH_MEMORY);
return ERRCODE_NOT_ENOUGH_MEMORY;
static RESULT versaloon_fini(void)
{
- if (versaloon_usb_device_handle != NULL) {
+ if (versaloon_usb_device_handle) {
usbtoxxx_fini();
versaloon_free_want_pos();
uint16_t inlen;
#if PARAM_CHECK
- if (NULL == versaloon_buf) {
+ if (!versaloon_buf) {
LOG_BUG(ERRMSG_INVALID_BUFFER, TO_STR(versaloon_buf));
return ERRCODE_INVALID_BUFFER;
}
- if (NULL == voltage) {
+ if (!voltage) {
LOG_BUG(ERRMSG_INVALID_PARAMETER, __func__);
return ERRCODE_INVALID_PARAMETER;
}
" vsllink "
"-------------------------------------");
- while (cmd != NULL) {
+ while (cmd) {
switch (cmd->type) {
case JTAG_RUNTEST:
LOG_DEBUG_IO("runtest %i cycles, end in %s",
static int vsllink_interface_init(void)
{
vsllink_handle = malloc(sizeof(struct vsllink));
- if (NULL == vsllink_handle) {
+ if (!vsllink_handle) {
LOG_ERROR("unable to allocate memory");
return ERROR_FAIL;
}
tdi_buffer = malloc(tap_buffer_size);
tdo_buffer = malloc(tap_buffer_size);
tms_buffer = malloc(tap_buffer_size);
- if ((NULL == tdi_buffer) || (NULL == tdo_buffer) || (NULL == tms_buffer)) {
+ if ((!tdi_buffer) || (!tdo_buffer) || (!tms_buffer)) {
vsllink_quit();
return ERROR_FAIL;
}
* 2) didn't find the XDS110, and no devices are currently open
*/
- if (NULL != list) {
+ if (list) {
/* Free the device list, we're done with it */
libusb_free_device_list(list, 1);
}
/* On an error, clean up what we can */
if (0 != result) {
- if (NULL != dev) {
+ if (dev) {
/* Release the debug and data interface on the XDS110 */
(void)libusb_release_interface(dev, xds110.interface);
libusb_close(dev);
}
- if (NULL != ctx)
+ if (ctx)
libusb_exit(ctx);
xds110.ctx = NULL;
xds110.dev = NULL;
static void usb_disconnect(void)
{
- if (NULL != xds110.dev) {
+ if (xds110.dev) {
/* Release the debug and data interface on the XDS110 */
(void)libusb_release_interface(xds110.dev, xds110.interface);
libusb_close(xds110.dev);
xds110.dev = NULL;
}
- if (NULL != xds110.ctx) {
+ if (xds110.ctx) {
libusb_exit(xds110.ctx);
xds110.ctx = NULL;
}
retries++;
}
- if (NULL != written)
+ if (written)
*written = bytes_written;
return (result == 0 && size == bytes_written) ? true : false;
/* Abort now if we didn't receive a valid response */
if (!success) {
- if (NULL != total_bytes_read)
+ if (total_bytes_read)
*total_bytes_read = 0;
return false;
}
if (!success)
count = 0;
- if (NULL != total_bytes_read)
+ if (total_bytes_read)
*total_bytes_read = count;
return success;
int error = 0;
uint32_t bytes_read = 0;
- if (NULL == xds110.dev)
+ if (!xds110.dev)
return false;
while (!done && attempts > 0) {
DEFAULT_TIMEOUT);
if (success) {
- if (NULL != firmware_id)
+ if (firmware_id)
*firmware_id = xds110_get_u32(fw_id_pntr);
- if (NULL != hardware_id)
+ if (hardware_id)
*hardware_id = xds110_get_u16(hw_id_pntr);
}
DEFAULT_TIMEOUT);
if (success) {
- if (NULL != idcode)
+ if (idcode)
*idcode = xds110_get_u32(idcode_pntr);
}
DEFAULT_TIMEOUT);
if (success) {
- if (NULL != value)
+ if (value)
*value = xds110_get_u32(value_pntr);
}
bool success;
- if (NULL == value)
+ if (!value)
return false;
xds110.write_payload[0] = CMAPI_REG_WRITE;
bool success;
- if (NULL == path)
+ if (!path)
return false;
xds110.write_payload[0] = OCD_PATHMOVE;
/* Handle result of read attempt */
if (!success)
LOG_ERROR("XDS110: failed to read DAP register");
- else if (NULL != value)
+ else if (value)
*value = reg_value;
if (success && DAP_AP == type) {
{
struct jtag_command *cmd = jtag_command_queue;
- while (cmd != NULL) {
+ while (cmd) {
xds110_execute_command(cmd);
cmd = cmd->next;
}
if (hl_if.layout->api->speed == NULL)
return ERROR_OK;
- if (hl_if.handle == NULL) {
+ if (!hl_if.handle) {
/* pass speed as initial param as interface not open yet */
hl_if.param.initial_interface_speed = speed;
return ERROR_OK;
{
LOG_DEBUG("hl_layout_init");
- if (adapter->layout == NULL) {
+ if (!adapter->layout) {
LOG_ERROR("no layout specified");
return ERROR_FAIL;
}
{
const char *cp = Jim_GetString(o, NULL);
struct jtag_tap *t = cp ? jtag_tap_by_string(cp) : NULL;
- if (NULL == cp)
+ if (!cp)
cp = "(unknown)";
- if (NULL == t)
+ if (!t)
Jim_SetResultFormatted(interp, "Tap '%s' could not be found", cp);
return t;
}
assert(e == JIM_OK);
tap = jtag_tap_by_jim_obj(interp, args[1]);
- if (tap == NULL)
+ if (!tap)
return JIM_ERR;
num_fields = (argc-2)/2;
if (goi->isconfigure) {
if (!found)
jteap = calloc(1, sizeof(*jteap));
- else if (NULL != jteap->body)
+ else if (jteap->body)
Jim_DecrRefCount(goi->interp, jteap->body);
jteap->interp = goi->interp;
struct jtag_tap *t;
t = jtag_tap_by_jim_obj(goi.interp, goi.argv[0]);
- if (t == NULL)
+ if (!t)
return JIM_ERR;
if (strcasecmp(cmd_name, "tapisenabled") == 0) {
Jim_Obj *o;
jim_getopt_obj(&goi, &o);
t = jtag_tap_by_jim_obj(goi.interp, o);
- if (t == NULL)
+ if (!t)
return JIM_ERR;
return jtag_tap_configure_cmd(&goi, t);
int retval;
for (i = 0; i < num_fields; i++) {
tap = jtag_tap_by_string(CMD_ARGV[i*2]);
- if (tap == NULL) {
+ if (!tap) {
free(fields);
command_print(CMD, "Tap: %s unknown", CMD_ARGV[i*2]);
static int virtex2_set_instr(struct jtag_tap *tap, uint32_t new_instr)
{
- if (tap == NULL)
+ if (!tap)
return ERROR_FAIL;
if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != new_instr) {
return ERROR_COMMAND_SYNTAX_ERROR;
tap = jtag_tap_by_string(CMD_ARGV[1]);
- if (tap == NULL) {
+ if (!tap) {
command_print(CMD, "Tap: %s does not exist", CMD_ARGV[1]);
return ERROR_OK;
}
}
input_file = fopen(filename, "rb");
- if (input_file == NULL) {
+ if (!input_file) {
LOG_ERROR("couldn't open %s: %s", filename, strerror(errno));
return ERROR_PLD_FILE_LOAD_FAILED;
}
unsigned int tasks_found = 0;
const struct freertos_params *param;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -1;
param = (const struct freertos_params *) rtos->rtos_specific_params;
- if (rtos->symbols == NULL) {
+ if (!rtos->symbols) {
LOG_ERROR("No symbols for FreeRTOS");
return -3;
}
const struct freertos_params *param;
int64_t stack_ptr = 0;
- if (rtos == NULL)
+ if (!rtos)
return -1;
if (thread_id == 0)
return -2;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -1;
param = (const struct freertos_params *) rtos->rtos_specific_params;
int retval;
const struct freertos_params *param;
- if (rtos == NULL)
+ if (!rtos)
return -1;
if (thread_id == 0)
return -2;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -3;
param = (const struct freertos_params *) rtos->rtos_specific_params;
{
const struct threadx_params *param = (const struct threadx_params *) rtos->rtos_specific_params;
- if (param->fn_get_stacking_info != NULL)
+ if (param->fn_get_stacking_info)
return param->fn_get_stacking_info(rtos, stack_ptr);
return param->stacking_info + 0;
{
const struct threadx_params *param;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return 0; /* invalid */
param = (const struct threadx_params *) rtos->rtos_specific_params;
- if (param->fn_is_thread_id_valid != NULL)
+ if (param->fn_is_thread_id_valid)
return param->fn_is_thread_id_valid(rtos, thread_id);
return (thread_id != 0);
int thread_list_size = 0;
const struct threadx_params *param;
- if (rtos == NULL)
+ if (!rtos)
return -1;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -3;
param = (const struct threadx_params *) rtos->rtos_specific_params;
- if (rtos->symbols == NULL) {
+ if (!rtos->symbols) {
LOG_ERROR("No symbols for ThreadX");
return -4;
}
int retval;
const struct threadx_params *param;
- if (rtos == NULL)
+ if (!rtos)
return -1;
if (!is_thread_id_valid(rtos, thread_id))
return -2;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -3;
param = (const struct threadx_params *) rtos->rtos_specific_params;
const struct rtos_register_stacking *stacking_info =
get_stacking_info(rtos, stack_ptr);
- if (stacking_info == NULL) {
+ if (!stacking_info) {
LOG_ERROR("Unknown stacking info for thread id=0x%" PRIx64, (uint64_t)thread_id);
return -6;
}
const struct threadx_params *param;
- if (rtos == NULL)
+ if (!rtos)
return -1;
if (thread_id == 0)
return -2;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -3;
param = (const struct threadx_params *) rtos->rtos_specific_params;
- if (rtos->symbols == NULL) {
+ if (!rtos->symbols) {
LOG_ERROR("No symbols for ThreadX");
return -3;
}
const struct chibios_params *param;
uint32_t stack_ptr = 0;
- if ((rtos == NULL) || (thread_id == 0) ||
- (rtos->rtos_specific_params == NULL))
+ if ((!rtos) || (thread_id == 0) ||
+ (!rtos->rtos_specific_params))
return -1;
param = (const struct chibios_params *) rtos->rtos_specific_params;
int thread_list_size = 0;
const struct ecos_params *param;
- if (rtos == NULL)
+ if (!rtos)
return -1;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -3;
param = (const struct ecos_params *) rtos->rtos_specific_params;
- if (rtos->symbols == NULL) {
+ if (!rtos->symbols) {
LOG_ERROR("No symbols for eCos");
return -4;
}
int retval;
const struct ecos_params *param;
- if (rtos == NULL)
+ if (!rtos)
return -1;
if (thread_id == 0)
return -2;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -3;
param = (const struct ecos_params *) rtos->rtos_specific_params;
int retval;
const struct embkernel_params *param;
- if (rtos == NULL)
+ if (!rtos)
return -1;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -3;
- if (rtos->symbols == NULL) {
+ if (!rtos->symbols) {
LOG_ERROR("No symbols for embKernel");
return -4;
}
const struct embkernel_params *param;
int64_t stack_ptr = 0;
- if (rtos == NULL)
+ if (!rtos)
return -1;
if (thread_id == 0)
return -2;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -1;
param = (const struct embkernel_params *) rtos->rtos_specific_params;
int64_t current_thread = 0;
enum target_debug_reason current_reason = DBG_REASON_UNDEFINED;
- if (rtos == NULL)
+ if (!rtos)
return -1;
target = rtos->target;
static struct target *hwthread_find_thread(struct target *target, int64_t thread_id)
{
/* Find the thread with that thread_id */
- if (target == NULL)
+ if (!target)
return NULL;
if (target->smp) {
for (struct target_list *head = target->head; head != NULL; head = head->next) {
static int hwthread_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
struct rtos_reg **rtos_reg_list, int *rtos_reg_list_size)
{
- if (rtos == NULL)
+ if (!rtos)
return ERROR_FAIL;
struct target *target = rtos->target;
struct target *curr = hwthread_find_thread(target, thread_id);
- if (curr == NULL)
+ if (!curr)
return ERROR_FAIL;
if (!target_was_examined(curr))
static int hwthread_get_thread_reg(struct rtos *rtos, int64_t thread_id,
uint32_t reg_num, struct rtos_reg *rtos_reg)
{
- if (rtos == NULL)
+ if (!rtos)
return ERROR_FAIL;
struct target *target = rtos->target;
struct target *curr = hwthread_find_thread(target, thread_id);
- if (curr == NULL) {
+ if (!curr) {
LOG_ERROR("Couldn't find RTOS thread for id %" PRId64 ".", thread_id);
return ERROR_FAIL;
}
static int hwthread_set_reg(struct rtos *rtos, uint32_t reg_num, uint8_t *reg_value)
{
- if (rtos == NULL)
+ if (!rtos)
return ERROR_FAIL;
struct target *target = rtos->target;
struct target *curr = hwthread_find_thread(target, rtos->current_thread);
- if (curr == NULL)
+ if (!curr)
return ERROR_FAIL;
struct reg *reg = register_get_by_number(curr->reg_cache, reg_num, true);
struct target *target = get_target_from_connection(connection);
struct target *curr = hwthread_find_thread(target, thread_id);
- if (curr == NULL)
+ if (!curr)
return ERROR_FAIL;
*p_target = curr;
found = 1;
else
next = next->next;
- } while ((found == 0) && (next != tmp) && (next != NULL));
+ } while ((found == 0) && (next != tmp) && (next));
if (found == 0) {
LOG_ERROR("could not find thread: %" PRIx64, thread_id);
struct current_thread *ctt = linux_os->current_threads;
/* invalid current threads content */
- while (ctt != NULL) {
+ while (ctt) {
ctt->threadid = -1;
ctt->TS = 0xdeadbeef;
ctt = ctt->next;
linux_os->current_threads;
cpu = head->target->coreid;
- while ((ct != NULL) && (ct->core_id != (int32_t) cpu))
+ while ((ct) && (ct->core_id != (int32_t) cpu))
ct = ct->next;
- if ((ct != NULL) && (ct->TS == 0xdeadbeef))
+ if ((ct) && (ct->TS == 0xdeadbeef))
ct->TS = TS;
else
LOG_ERROR
{
ct->next = NULL;
- if (currents == NULL) {
+ if (!currents) {
currents = ct;
return currents;
} else {
struct current_thread *temp = currents;
- while (temp->next != NULL)
+ while (temp->next)
temp = temp->next;
temp->next = ct;
t->next = NULL;
if (*last == NULL)
- if (task_list == NULL) {
+ if (!task_list) {
task_list = t;
return task_list;
} else {
struct threads *temp = task_list;
- while (temp->next != NULL)
+ while (temp->next)
temp = temp->next;
temp->next = t;
struct current_thread *ct = linux_os->current_threads;
#ifdef PID_CHECK
- while ((ct != NULL) && (ct->pid != pid))
+ while ((ct) && (ct->pid != pid))
#else
- while ((ct != NULL) && (ct->TS != base_addr))
+ while ((ct) && (ct->TS != base_addr))
#endif
ct = ct->next;
#ifdef PID_CHECK
- if ((ct != NULL) && (ct->pid == pid))
+ if ((ct) && (ct->pid == pid))
#else
- if ((ct != NULL) && (ct->TS == base_addr))
+ if ((ct) && (ct->TS == base_addr))
#endif
return 1;
target->rtos->rtos_specific_params;
struct threads *old, *temp = linux_os->thread_list;
- while (temp != NULL) {
+ while (temp) {
old = temp;
free(temp->context);
t->status = 1;
t->next = NULL;
- if (temp == NULL)
+ if (!temp)
linux_os->thread_list = t;
else {
- while (temp->next != NULL)
+ while (temp->next)
temp = temp->next;
t->next = NULL;
struct current_thread *ct = linux_os->current_threads;
struct threads *t = NULL;
- while ((ct != NULL)) {
+ while ((ct)) {
if (ct->threadid == -1) {
/* un-identified thread */
/* search in the list of threads if pid
already present */
- while ((thread_list != NULL) && (found == 0)) {
+ while ((thread_list) && (found == 0)) {
#ifdef PID_CHECK
if (thread_list->pid == t->pid) {
#else
linux_os->thread_count = 0;
/*thread_list = thread_list->next; skip init_task*/
- while (thread_list != NULL) {
+ while (thread_list) {
thread_list->status = 0; /*setting all tasks to dead state*/
free(thread_list->context);
thread_list = linux_os->thread_list;
- while (thread_list != NULL) {
+ while (thread_list) {
#ifdef PID_CHECK
if (t->pid == thread_list->pid) {
#else
tmp_str += sprintf(tmp_str, "m");
struct threads *temp = linux_os->thread_list;
- while (temp != NULL) {
+ while (temp) {
tmp_str += sprintf(tmp_str, "%016" PRIx64, temp->threadid);
temp = temp->next;
if (temp)
target->rtos->rtos_specific_params;
struct threads *temp = linux_os->thread_list;
- while (temp != NULL) {
+ while (temp) {
if (temp->threadid == linux_os->preupdtate_threadid_count + 1) {
/*LOG_INFO("FOUND");*/
found = 1;
temp = temp->next;
- while (temp != NULL) {
+ while (temp) {
/*LOG_INFO("INTO GDB THREAD UPDATE WHILE");*/
tmp_strr += sprintf(tmp_strr, ",");
tmp_strr +=
/*LOG_INFO("lookup extra info for thread %" SCNx64, threadid);*/
struct threads *temp = linux_os->thread_list;
- while (temp != NULL) {
+ while (temp) {
if (temp->threadid == threadid) {
char *pid = " PID: ";
char *pid_current = "*PID: ";
struct threads *temp = linux_os->thread_list;
struct threads *prev = NULL;
- while (temp != NULL) {
+ while (temp) {
if (temp->threadid == threadid) {
if (temp->status != 0) {
gdb_put_packet(connection, "OK", 2);
retval = linux_task_update(target, 1);
struct threads *temp = linux_os->thread_list;
- while (temp != NULL) {
+ while (temp) {
if (temp->threadid == threadid) {
if (temp->status == 1) {
gdb_put_packet(connection, "OK", 2);
struct current_thread *ct = linux_os->current_threads;
/* select to display the current thread of the selected target */
- while ((ct != NULL) && (ct->core_id != target->coreid))
+ while ((ct) && (ct->core_id != target->coreid))
ct = ct->next;
int64_t current_gdb_thread_rq;
if (linux_os->threads_lookup == 1) {
- if ((ct != NULL) && (ct->threadid == -1)) {
+ if ((ct) && (ct->threadid == -1)) {
ct = linux_os->current_threads;
- while ((ct != NULL) && (ct->threadid == -1))
+ while ((ct) && (ct->threadid == -1))
ct = ct->next;
}
- if (ct == NULL) {
+ if (!ct) {
/* no current thread can be identified
* any way with smp */
LOG_INFO("no current thread identified");
struct threads t;
ct = linux_os->current_threads;
- while ((ct != NULL) && (ct->threadid == -1)) {
+ while ((ct) && (ct->threadid == -1)) {
t.base_addr = ct->TS;
get_name(target, &t);
LOG_INFO("name of unidentified thread %s",
break;
} else if (strncmp(packet, "qfThreadInfo", 12) == 0) {
- if (linux_os->thread_list == NULL) {
+ if (!linux_os->thread_list) {
retval = linux_gdb_thread_packet(target,
connection,
packet,
if (linux_os->threads_lookup == 1) {
ct = linux_os->current_threads;
- while ((ct != NULL) && (ct->core_id) != target->coreid)
+ while ((ct) && (ct->core_id) != target->coreid)
ct = ct->next;
- if ((ct != NULL) && (ct->threadid == -1)) {
+ if ((ct) && (ct->threadid == -1)) {
ct = linux_os->current_threads;
- while ((ct != NULL) && (ct->threadid == -1))
+ while ((ct) && (ct->threadid == -1))
ct = ct->next;
}
- if ((ct != NULL) && (ct->threadid !=
+ if ((ct) && (ct->threadid !=
target->rtos->current_threadid)
&& (target->rtos->current_threadid != -1))
LOG_WARNING("WARNING! current GDB thread do not match "
tmp += sprintf(tmp, "PID\t\tCPU\t\tASID\t\tNAME\n");
tmp += sprintf(tmp, "---\t\t---\t\t----\t\t----\n");
- while (temp != NULL) {
+ while (temp) {
if (temp->status) {
if (temp->context)
tmp +=
rtos->thread_count = task_queue_size;
rtos->current_thread = 0;
rtos->thread_details = calloc(rtos->thread_count, sizeof(struct thread_detail));
- if (NULL == rtos->thread_details)
+ if (!rtos->thread_details)
return ERROR_FAIL;
/* loop over each task and setup thread details,
uint32_t i;
uint8_t state;
- if (rtos->symbols == NULL) {
+ if (!rtos->symbols) {
LOG_ERROR("No symbols for NuttX");
return -3;
}
unsigned int tasks_found = 0;
const struct riot_params *param;
- if (rtos == NULL)
+ if (!rtos)
return ERROR_FAIL;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return ERROR_FAIL;
param = (const struct riot_params *)rtos->rtos_specific_params;
- if (rtos->symbols == NULL) {
+ if (!rtos->symbols) {
LOG_ERROR("No symbols for RIOT");
return ERROR_FAIL;
}
/* Allocate memory for thread description */
rtos->thread_details = calloc(thread_count, sizeof(struct thread_detail));
- if (rtos->thread_details == NULL) {
+ if (!rtos->thread_details) {
LOG_ERROR("RIOT: out of memory");
return ERROR_FAIL;
}
int retval;
const struct riot_params *param;
- if (rtos == NULL)
+ if (!rtos)
return ERROR_FAIL;
if (thread_id == 0)
return ERROR_FAIL;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return ERROR_FAIL;
param = (const struct riot_params *)rtos->rtos_specific_params;
int gdb_thread_packet(struct connection *connection, char const *packet, int packet_size)
{
struct target *target = get_target_from_connection(connection);
- if (target->rtos == NULL)
+ if (!target->rtos)
return rtos_thread_packet(connection, packet, packet_size); /* thread not
*found*/
return target->rtos->gdb_thread_packet(connection, packet, packet_size);
struct target *target = get_target_from_connection(connection);
if (strncmp(packet, "qThreadExtraInfo,", 17) == 0) {
- if ((target->rtos != NULL) && (target->rtos->thread_details != NULL) &&
+ if ((target->rtos) && (target->rtos->thread_details != NULL) &&
(target->rtos->thread_count != 0)) {
threadid_t threadid = 0;
int found = -1;
sscanf(packet, "qThreadExtraInfo,%" SCNx64, &threadid);
- if ((target->rtos != NULL) && (target->rtos->thread_details != NULL)) {
+ if ((target->rtos) && (target->rtos->thread_details != NULL)) {
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 thread_detail *detail = &target->rtos->thread_details[found];
int str_size = 0;
- if (detail->thread_name_str != NULL)
+ if (detail->thread_name_str)
str_size += strlen(detail->thread_name_str);
- if (detail->extra_info_str != NULL)
+ if (detail->extra_info_str)
str_size += strlen(detail->extra_info_str);
char *tmp_str = calloc(str_size + 9, sizeof(char));
char *tmp_str_ptr = tmp_str;
- if (detail->thread_name_str != NULL)
+ if (detail->thread_name_str)
tmp_str_ptr += sprintf(tmp_str_ptr, "Name: %s", detail->thread_name_str);
- if (detail->extra_info_str != NULL) {
+ if (detail->extra_info_str) {
if (tmp_str_ptr != tmp_str)
tmp_str_ptr += sprintf(tmp_str_ptr, ", ");
tmp_str_ptr += sprintf(tmp_str_ptr, "%s", detail->extra_info_str);
return ERROR_OK;
} else if (strncmp(packet, "qfThreadInfo", 12) == 0) {
int i;
- if (target->rtos != NULL) {
+ if (target->rtos) {
if (target->rtos->thread_count == 0) {
gdb_put_packet(connection, "l", 1);
} else {
* otherwise it gets incorrectly handled */
return GDB_THREAD_PACKET_NOT_CONSUMED;
} else if (strncmp(packet, "qC", 2) == 0) {
- if (target->rtos != NULL) {
+ if (target->rtos) {
char buffer[19];
int size;
size = snprintf(buffer, 19, "QC%016" PRIx64, target->rtos->current_thread);
threadid_t threadid;
int found = -1;
sscanf(packet, "T%" SCNx64, &threadid);
- if ((target->rtos != NULL) && (target->rtos->thread_details != NULL)) {
+ if ((target->rtos) && (target->rtos->thread_details != NULL)) {
int thread_num;
for (thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) {
if (target->rtos->thread_details[thread_num].threadid == threadid) {
return ERROR_OK;
} else if (packet[0] == 'H') { /* Set current thread ( 'c' for step and continue, 'g' for
* all other operations ) */
- if ((packet[1] == 'g') && (target->rtos != NULL)) {
+ if ((packet[1] == 'g') && (target->rtos)) {
threadid_t threadid;
sscanf(packet, "Hg%16" SCNx64, &threadid);
LOG_DEBUG("RTOS: GDB requested to set current thread to 0x%" PRIx64, threadid);
{
struct target *target = get_target_from_connection(connection);
int64_t current_threadid = target->rtos->current_threadid;
- if ((target->rtos != NULL) && (current_threadid != -1) &&
+ if ((target->rtos) && (current_threadid != -1) &&
(current_threadid != 0) &&
((current_threadid != target->rtos->current_thread) ||
(target->smp))) { /* in smp several current thread are possible */
{
struct target *target = get_target_from_connection(connection);
int64_t current_threadid = target->rtos->current_threadid;
- if ((target->rtos != NULL) && (current_threadid != -1) &&
+ if ((target->rtos) && (current_threadid != -1) &&
(current_threadid != 0) &&
((current_threadid != target->rtos->current_thread) ||
(target->smp))) { /* in smp several current thread are possible */
{
struct target *target = get_target_from_connection(connection);
int64_t current_threadid = target->rtos->current_threadid;
- if ((target->rtos != NULL) &&
+ if ((target->rtos) &&
(target->rtos->type->set_reg != NULL) &&
(current_threadid != -1) &&
(current_threadid != 0)) {
#endif
int64_t new_stack_ptr;
- if (stacking->calculate_process_stack != NULL) {
+ if (stacking->calculate_process_stack) {
new_stack_ptr = stacking->calculate_process_stack(target,
stack_data, stacking, stack_ptr);
} else {
int rtos_update_threads(struct target *target)
{
- if ((target->rtos != NULL) && (target->rtos->type != NULL))
+ if ((target->rtos) && (target->rtos->type != NULL))
target->rtos->type->update_threads(target->rtos);
return ERROR_OK;
}
for (size_t i = 0; i < ARRAY_SIZE(ucos_iii_params_list); i++)
if (strcmp(ucos_iii_params_list[i].target_name, target->type->name) == 0) {
params = malloc(sizeof(*params) + (UCOS_III_MAX_THREADS * sizeof(*params->threads)));
- if (params == NULL) {
+ if (!params) {
LOG_ERROR("uCOS-III: out of memory");
return ERROR_FAIL;
}
struct ucos_iii_params *params = rtos->rtos_specific_params;
int retval;
- if (rtos->symbols == NULL) {
+ if (!rtos->symbols) {
LOG_ERROR("uCOS-III: symbol list not loaded");
return ERROR_FAIL;
}
if (!rtos_running) {
rtos->thread_details = calloc(1, sizeof(struct thread_detail));
- if (rtos->thread_details == NULL) {
+ if (!rtos->thread_details) {
LOG_ERROR("uCOS-III: out of memory");
return ERROR_FAIL;
}
}
rtos->thread_details = calloc(rtos->thread_count, sizeof(struct thread_detail));
- if (rtos->thread_details == NULL) {
+ if (!rtos->thread_details) {
LOG_ERROR("uCOS-III: out of memory");
return ERROR_FAIL;
}
LOG_INFO("Getting thread %" PRId64 " reg list", thread_id);
- if (rtos == NULL)
+ if (!rtos)
return ERROR_FAIL;
if (thread_id == 0)
return ERROR_FAIL;
params = rtos->rtos_specific_params;
- if (params == NULL)
+ if (!params)
return ERROR_FAIL;
addr = thread_id + params->offsets[OFFSET_T_STACK_POINTER]
fd_set read_fds;
struct gdb_connection *gdb_con = connection->priv;
int t;
- if (got_data == NULL)
+ if (!got_data)
got_data = &t;
*got_data = 0;
/* Does packet at least have a prefix that is printable?
* Look within the first 50 chars of the packet. */
const char *colon = memchr(packet, ':', MIN(50, packet_len));
- const bool packet_has_prefix = (colon != NULL);
+ const bool packet_has_prefix = (colon);
const bool packet_prefix_printable = (packet_has_prefix && nonprint > colon);
if (packet_prefix_printable) {
bin_size = strlen(line);
hex_buffer = malloc(bin_size * 2 + 2);
- if (hex_buffer == NULL)
+ if (!hex_buffer)
return ERROR_GDB_BUFFER_TOO_SMALL;
hex_buffer[0] = 'O';
sig_reply_len = snprintf(sig_reply, sizeof(sig_reply), "W00");
} else {
struct target *ct;
- if (target->rtos != NULL) {
+ if (target->rtos) {
target->rtos->current_threadid = target->rtos->current_thread;
target->rtos->gdb_target_for_threadid(connection, target->rtos->current_threadid, &ct);
} else {
}
current_thread[0] = '\0';
- if (target->rtos != NULL)
+ if (target->rtos)
snprintf(current_thread, sizeof(current_thread), "thread:%" PRIx64 ";",
target->rtos->current_thread);
LOG_DEBUG("-");
#endif
- if ((target->rtos != NULL) && (ERROR_OK == rtos_get_gdb_reg_list(connection)))
+ if ((target->rtos) && (ERROR_OK == rtos_get_gdb_reg_list(connection)))
return ERROR_OK;
retval = target_get_gdb_reg_list(target, ®_list, ®_list_size,
assert(reg_packet_size > 0);
reg_packet = malloc(reg_packet_size + 1); /* plus one for string termination null */
- if (reg_packet == NULL)
+ if (!reg_packet)
return ERROR_FAIL;
reg_packet_p = reg_packet;
LOG_DEBUG("-");
#endif
- if ((target->rtos != NULL) && (ERROR_OK == rtos_get_gdb_reg(connection, reg_num)))
+ if ((target->rtos) && (ERROR_OK == rtos_get_gdb_reg(connection, reg_num)))
return ERROR_OK;
retval = target_get_gdb_reg_list_noread(target, ®_list, ®_list_size,
uint8_t *bin_buf = malloc(chars / 2);
gdb_target_to_reg(target, separator + 1, chars, bin_buf);
- if ((target->rtos != NULL) &&
+ if ((target->rtos) &&
(ERROR_OK == rtos_set_reg(connection, reg_num, bin_buf))) {
free(bin_buf);
gdb_put_packet(connection, "OK", 2);
{
/* Locate the annex. */
const char *annex_end = strchr(buf, ':');
- if (annex_end == NULL)
+ if (!annex_end)
return ERROR_FAIL;
/* After the read marker and annex, qXfer looks like a
*len = strtoul(separator + 1, NULL, 16);
/* Extract the annex if needed */
- if (annex != NULL) {
+ if (annex) {
*annex = strndup(buf, annex_end - buf);
if (*annex == NULL)
return ERROR_FAIL;
} else if (type->type_class == REG_TYPE_CLASS_UNION) {
struct reg_data_type_union_field *field;
field = type->reg_type_union->fields;
- while (field != NULL) {
+ while (field) {
struct reg_data_type *data_type = field->type;
if (data_type->type == REG_TYPE_ARCH_DEFINED) {
if (lookup_add_arch_defined_types(arch_defined_types_list, data_type->id,
type->id);
field = type->reg_type_union->fields;
- while (field != NULL) {
+ while (field) {
xml_printf(&retval, tdesc, pos, size,
"<field name=\"%s\" type=\"%s\"/>\n",
field->name, field->type->id);
xml_printf(&retval, tdesc, pos, size,
"<struct id=\"%s\" size=\"%" PRIu32 "\">\n",
type->id, type->reg_type_struct->size);
- while (field != NULL) {
+ while (field) {
xml_printf(&retval, tdesc, pos, size,
"<field name=\"%s\" start=\"%" PRIu32 "\" end=\"%" PRIu32 "\" type=\"%s\" />\n",
field->name, field->bitfield->start, field->bitfield->end,
field = field->next;
}
} else {
- while (field != NULL) {
+ while (field) {
struct reg_data_type *data_type = field->type;
if (data_type->type == REG_TYPE_ARCH_DEFINED) {
if (lookup_add_arch_defined_types(arch_defined_types_list, data_type->id,
xml_printf(&retval, tdesc, pos, size,
"<struct id=\"%s\">\n",
type->id);
- while (field != NULL) {
+ while (field) {
xml_printf(&retval, tdesc, pos, size,
"<field name=\"%s\" type=\"%s\"/>\n",
field->name, field->type->id);
struct reg_data_type_flags_field *field;
field = type->reg_type_flags->fields;
- while (field != NULL) {
+ while (field) {
xml_printf(&retval, tdesc, pos, size,
"<field name=\"%s\" start=\"%" PRIu32 "\" end=\"%" PRIu32 "\" type=\"%s\" />\n",
field->name, field->bitfield->start, field->bitfield->end,
/* generate architecture element if supported by target */
architecture = target_get_gdb_arch(target);
- if (architecture != NULL)
+ if (architecture)
xml_printf(&retval, &tdesc, &pos, &size,
"<architecture>%s</architecture>\n", architecture);
/* generate target description according to register list */
- if (features != NULL) {
+ if (features) {
while (features[current_feature]) {
char const **arch_defined_types = NULL;
int num_arch_defined_types = 0;
static int gdb_get_target_description_chunk(struct target *target, struct target_desc_format *target_desc,
char **chunk, int32_t offset, uint32_t length)
{
- if (target_desc == NULL) {
+ if (!target_desc) {
LOG_ERROR("Unable to Generate Target Description");
return ERROR_FAIL;
}
char *tdesc = target_desc->tdesc;
uint32_t tdesc_length = target_desc->tdesc_length;
- if (tdesc == NULL) {
+ if (!tdesc) {
int retval = gdb_generate_target_description(target, &tdesc);
if (retval != ERROR_OK) {
LOG_ERROR("Unable to Generate Target Description");
"<?xml version=\"1.0\"?>\n"
"<threads>\n");
- if (rtos != NULL) {
+ if (rtos) {
for (int i = 0; i < rtos->thread_count; i++) {
struct thread_detail *thread_detail = &rtos->thread_details[i];
xml_printf(&retval, &thread_list, &pos, &size,
"<thread id=\"%" PRIx64 "\">", thread_detail->threadid);
- if (thread_detail->thread_name_str != NULL)
+ if (thread_detail->thread_name_str)
xml_printf(&retval, &thread_list, &pos, &size,
"Name: %s", thread_detail->thread_name_str);
- if (thread_detail->extra_info_str != NULL) {
- if (thread_detail->thread_name_str != NULL)
+ if (thread_detail->extra_info_str) {
+ if (thread_detail->thread_name_str)
xml_printf(&retval, &thread_list, &pos, &size,
", ");
xml_printf(&retval, &thread_list, &pos, &size,
packet_size -= 2;
thread_id = strtoll(parse, &endp, 16);
- if (endp != NULL) {
+ if (endp) {
packet_size -= endp - parse;
parse = endp;
}
- if (target->rtos != NULL) {
+ if (target->rtos) {
/* FIXME: why is this necessary? rtos state should be up-to-date here already! */
rtos_update_threads(target);
return NULL;
const char *end = strchr(hex, sep);
- if (end == NULL)
+ if (!end)
hexlen = strlen(hex);
else
hexlen = end - hex;
size_t count = hexlen / 2;
char *decoded = malloc(count + 1);
- if (decoded == NULL)
+ if (!decoded)
return NULL;
size_t converted = unhexify((void *)decoded, hex, count);
cmdline = new_cmdline;
}
- if (cmdline != NULL) {
- if (target->semihosting != NULL) {
+ if (cmdline) {
+ if (target->semihosting) {
LOG_INFO("GDB set inferior command line to '%s'", cmdline);
free(target->semihosting->cmdline);
target->semihosting->cmdline = cmdline;
length = packet_size - (parse - packet);
/* create a new image if there isn't already one */
- if (gdb_connection->vflash_image == NULL) {
+ if (!gdb_connection->vflash_image) {
gdb_connection->vflash_image = malloc(sizeof(struct image));
image_open(gdb_connection->vflash_image, "", "build");
}
int ret;
gdb_service = malloc(sizeof(struct gdb_service));
- if (NULL == gdb_service)
+ if (!gdb_service)
return -ENOMEM;
LOG_INFO("starting gdb server for %s on %s", target_name(target), port);
int gdb_target_add_all(struct target *target)
{
- if (NULL == target) {
+ if (!target) {
LOG_WARNING("gdb services need one or more targets defined");
return ERROR_OK;
}
- while (NULL != target) {
+ while (target) {
int retval = gdb_target_add_one(target);
if (retval != ERROR_OK)
return retval;
if (CMD_ARGC != 0)
return ERROR_COMMAND_SYNTAX_ERROR;
- if (current_gdb_connection == NULL) {
+ if (!current_gdb_connection) {
command_print(CMD,
"gdb_sync command can only be run from within gdb using \"monitor gdb_sync\"");
return ERROR_FAIL;
size_t size_written;
char *tdesc_filename = alloc_printf("%s.xml", target_type_name(target));
- if (tdesc_filename == NULL) {
+ if (!tdesc_filename) {
retval = ERROR_FAIL;
goto out;
}
memset(&c->sin, 0, sizeof(c->sin));
c->sin.sin_family = AF_INET;
- if (bindto_name == NULL)
+ if (!bindto_name)
c->sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
else {
hp = gethostbyname(bindto_name);
- if (hp == NULL) {
+ if (!hp) {
LOG_ERROR("couldn't resolve bindto address: %s", bindto_name);
close_socket(c->fd);
free_service(c);
struct tcl_connection *tclc;
tclc = calloc(1, sizeof(struct tcl_connection));
- if (tclc == NULL)
+ if (!tclc)
return ERROR_CONNECTION_REJECTED;
tclc->tc_line_size = TCL_LINE_INITIAL;
tclc->tc_line = malloc(tclc->tc_line_size);
- if (tclc->tc_line == NULL) {
+ if (!tclc->tc_line) {
free(tclc);
return ERROR_CONNECTION_REJECTED;
}
connection->priv = tclc;
struct target *target = get_current_target_or_null(connection->cmd_ctx);
- if (target != NULL)
+ if (target)
tclc->tc_laststate = target->state;
/* store the connection object on cmd_ctx so we can access it from command handlers */
}
tclc = connection->priv;
- if (tclc == NULL)
+ if (!tclc)
return ERROR_CONNECTION_REJECTED;
/* push as much data into the line as possible */
tc_line_size_new = TCL_LINE_MAX;
tc_line_new = realloc(tclc->tc_line, tc_line_size_new);
- if (tc_line_new == NULL) {
+ if (!tc_line_new) {
tclc->tc_linedrop = 1;
} else {
tclc->tc_line = tc_line_new;
char *history = get_home_dir(TELNET_HISTORY);
- if (history == NULL) {
+ if (!history) {
LOG_INFO("unable to get user home directory, telnet history will be disabled");
return;
}
char *history = get_home_dir(TELNET_HISTORY);
- if (history == NULL) {
+ if (!history) {
LOG_INFO("unable to get user home directory, telnet history will be disabled");
return;
}
static void svf_free_xxd_para(struct svf_xxr_para *para)
{
- if (NULL != para) {
+ if (para) {
free(para->tdi);
para->tdi = NULL;
svf_ignore_error = 1;
else {
svf_fd = fopen(CMD_ARGV[i], "r");
- if (svf_fd == NULL) {
+ if (!svf_fd) {
int err = errno;
command_print(CMD, "open(\"%s\"): %s", CMD_ARGV[i], strerror(err));
/* no need to free anything now */
}
}
- if (svf_fd == NULL)
+ if (!svf_fd)
return ERROR_COMMAND_SYNTAX_ERROR;
/* get time */
svf_check_tdo_para_index = 0;
svf_check_tdo_para = malloc(sizeof(struct svf_check_tdo_para) * SVF_CHECK_TDO_PARA_SIZE);
- if (NULL == svf_check_tdo_para) {
+ if (!svf_check_tdo_para) {
LOG_ERROR("not enough memory");
ret = ERROR_FAIL;
goto free_all;
if (cmd_pos + 3 > svf_command_buffer_size) {
svf_command_buffer = realloc(svf_command_buffer, cmd_pos + 3);
svf_command_buffer_size = cmd_pos + 3;
- if (svf_command_buffer == NULL) {
+ if (!svf_command_buffer) {
LOG_ERROR("not enough memory");
return ERROR_FAIL;
}
}
/* If TDO is absent, no comparison is needed, set the mask to 0 */
if (!(xxr_para_tmp->data_mask & XXR_TDO)) {
- if (NULL == xxr_para_tmp->tdo) {
+ if (!xxr_para_tmp->tdo) {
if (ERROR_OK !=
svf_adjust_array_length(&xxr_para_tmp->tdo, i_tmp,
xxr_para_tmp->len)) {
return ERROR_FAIL;
}
}
- if (NULL == xxr_para_tmp->mask) {
+ if (!xxr_para_tmp->mask) {
if (ERROR_OK !=
svf_adjust_array_length(&xxr_para_tmp->mask, i_tmp,
xxr_para_tmp->len)) {
if (num_of_argu > 2) {
/* STATE pathstate1 ... stable_state */
path = malloc((num_of_argu - 1) * sizeof(tap_state_t));
- if (NULL == path) {
+ if (!path) {
LOG_ERROR("not enough memory");
return ERROR_FAIL;
}
LOG_DEBUG("target %s exc %i", target_name(target), exc_target);
- while (head != NULL) {
+ while (head) {
struct target *curr = head->target;
struct armv8_common *armv8 = target_to_armv8(curr);
head = head->next;
LOG_DEBUG("target %s prepared", target_name(curr));
- if (first == NULL)
+ if (!first)
first = curr;
}
if (curr->state == TARGET_HALTED)
continue;
/* remember the gdb_service->target */
- if (curr->gdb_service != NULL)
+ if (curr->gdb_service)
gdb_target = curr->gdb_service->target;
/* skip it */
if (curr == gdb_target)
break;
}
/* remember the first valid target in the group */
- if (first == NULL)
+ if (!first)
first = curr;
}
if (retval != ERROR_OK)
return retval;
- if (first != NULL)
+ if (first)
retval = aarch64_do_restart_one(first, RESTART_LAZY);
if (retval != ERROR_OK) {
LOG_DEBUG("error restarting target %s", target_name(first));
uint32_t tmp0, tmp1, tmp2, tmp3;
debug = ttypr = cpuid = 0;
- if (pc == NULL)
+ if (!pc)
return ERROR_FAIL;
if (pc->adiv5_config.ap_num == DP_APSEL_INVALID) {
LOG_DEBUG("ttypr = 0x%08" PRIx64, ttypr);
LOG_DEBUG("debug = 0x%08" PRIx64, debug);
- if (pc->cti == NULL)
+ if (!pc->cti)
return ERROR_FAIL;
armv8->cti = pc->cti;
return ERROR_FAIL;
aarch64 = calloc(1, sizeof(struct aarch64_common));
- if (aarch64 == NULL) {
+ if (!aarch64) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
int e;
pc = (struct aarch64_private_config *)target->private_config;
- if (pc == NULL) {
+ if (!pc) {
pc = calloc(1, sizeof(struct aarch64_private_config));
pc->adiv5_config.ap_num = DP_APSEL_INVALID;
target->private_config = pc;
if (e != JIM_OK)
return e;
cti = cti_instance_by_jim_obj(goi->interp, o_cti);
- if (cti == NULL) {
+ if (!cti) {
Jim_SetResultString(goi->interp, "CTI name invalid!", -1);
return JIM_ERR;
}
{
struct target *target = get_current_target(CMD_CTX);
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("No target selected");
return ERROR_FAIL;
}
if (CMD_ARGC > 0) {
n = jim_nvp_name2value_simple(nvp_maskisr_modes, CMD_ARGV[0]);
- if (n->name == NULL) {
+ if (!n->name) {
LOG_ERROR("Unknown parameter: %s - should be off or on", CMD_ARGV[0]);
return ERROR_COMMAND_SYNTAX_ERROR;
}
}
context = current_command_context(interp);
- assert(context != NULL);
+ assert(context);
target = get_current_target(context);
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("%s: no current target", __func__);
return JIM_ERR;
}
if (list_empty(&dap->cmd_pool)) {
pool = calloc(1, sizeof(struct dap_cmd_pool));
- if (pool == NULL)
+ if (!pool)
return NULL;
} else {
pool = list_first_entry(&dap->cmd_pool, struct dap_cmd_pool, lh);
cmd->instr = instr;
cmd->reg_addr = reg_addr;
cmd->rnw = rnw;
- if (outvalue != NULL)
+ if (outvalue)
memcpy(cmd->outvalue_buf, outvalue, 4);
- cmd->invalue = (invalue != NULL) ? invalue : cmd->invalue_buf;
+ cmd->invalue = (invalue) ? invalue : cmd->invalue_buf;
cmd->memaccess_tck = memaccess_tck;
return cmd;
cmd->fields[0].num_bits = 3;
buf_set_u32(&cmd->out_addr_buf, 0, 3, ((cmd->reg_addr >> 1) & 0x6) | (cmd->rnw & 0x1));
cmd->fields[0].out_value = &cmd->out_addr_buf;
- cmd->fields[0].in_value = (ack != NULL) ? ack : &cmd->ack;
+ cmd->fields[0].in_value = (ack) ? ack : &cmd->ack;
/* NOTE: if we receive JTAG_ACK_WAIT, the previous operation did not
* complete; data we write is discarded, data we read is unpredictable.
int retval;
cmd = dap_cmd_new(dap, instr, reg_addr, rnw, outvalue, invalue, memaccess_tck);
- if (cmd != NULL)
+ if (cmd)
cmd->dp_select = dap->select;
else
return ERROR_JTAG_DEVICE_ERROR;
{
int retval = ERROR_OK;
- if (dap->last_read != NULL) {
+ if (dap->last_read) {
retval = adi_jtag_dp_scan_u32(dap, JTAG_DP_DPACC,
DP_RDBUFF, DPAP_READ, 0, dap->last_read, 0, NULL);
dap->last_read = NULL;
/* For reads, collect posted value; RDBUFF has no other effect.
* Assumes read gets acked with OK/FAULT, and CTRL_STAT says "OK".
*/
- if ((rnw == DPAP_READ) && (invalue != NULL)) {
+ if ((rnw == DPAP_READ) && (invalue)) {
retval = adi_jtag_dp_scan_u32(dap, JTAG_DP_DPACC,
DP_RDBUFF, DPAP_READ, 0, invalue, 0, NULL);
if (retval != ERROR_OK)
}
}
- if (prev != NULL) {
+ if (prev) {
log_dap_cmd("LST", el);
/*
*/
tmp = dap_cmd_new(dap, JTAG_DP_DPACC,
DP_RDBUFF, DPAP_READ, NULL, NULL, 0);
- if (tmp == NULL) {
+ if (!tmp) {
retval = ERROR_JTAG_DEVICE_ERROR;
goto done;
}
el = list_first_entry(&replay_list, struct dap_cmd, lh);
tmp = dap_cmd_new(dap, JTAG_DP_DPACC,
DP_SELECT, DPAP_WRITE, (uint8_t *)&el->dp_select, NULL, 0);
- if (tmp == NULL) {
+ if (!tmp) {
retval = ERROR_JTAG_DEVICE_ERROR;
goto done;
}
static void swd_finish_read(struct adiv5_dap *dap)
{
const struct swd_driver *swd = adiv5_dap_swd_driver(dap);
- if (dap->last_read != NULL) {
+ if (dap->last_read) {
swd->read_reg(swd_cmd(true, false, DP_RDBUFF), dap->last_read, 0);
dap->last_read = NULL;
}
static int get_current_actionpoint(struct target *target,
struct arc_actionpoint **actionpoint)
{
- assert(target != NULL);
- assert(actionpoint != NULL);
+ assert(target);
+ assert(actionpoint);
uint32_t debug_ah;
/* Check if actionpoint caused halt */
struct arc_actionpoint *actionpoint = NULL;
CHECK_RETVAL(get_current_actionpoint(target, &actionpoint));
- if (actionpoint != NULL) {
+ if (actionpoint) {
if (!actionpoint->used)
LOG_WARNING("Target halted by an unused actionpoint.");
struct arc_actionpoint *actionpoint = NULL;
CHECK_RETVAL(get_current_actionpoint(target, &actionpoint));
- if (actionpoint != NULL) {
+ if (actionpoint) {
if (!actionpoint->used)
LOG_WARNING("Target halted by unused actionpoint.");
/** Convert target handle to generic ARM target state handle. */
static inline struct arm *target_to_arm(struct target *target)
{
- assert(target != NULL);
+ assert(target);
return target->arch_info;
}
static inline bool is_arm(struct arm *arm)
{
- assert(arm != NULL);
+ assert(arm);
return arm->common_magic == ARM_COMMON_MAGIC;
}
{
struct arm11_common *arm11;
- if (target->tap == NULL)
+ if (!target->tap)
return ERROR_FAIL;
if (target->tap->ir_length != 5) {
unsigned bytes = sizeof(*readies)*readies_num;
readies = malloc(bytes);
- if (readies == NULL) {
+ if (!readies) {
LOG_ERROR("Out of memory allocating %u bytes", bytes);
return ERROR_FAIL;
}
struct breakpoint *breakpoint;
breakpoint = breakpoint_find(target,
buf_get_u32(arm->pc->value, 0, 32));
- if (breakpoint != NULL) {
+ if (breakpoint) {
LOG_DEBUG("unset breakpoint at 0x%8.8" TARGET_PRIxADDR " (id: %" PRIu32,
breakpoint->address,
breakpoint->unique_id);
/* the front-end may request us not to handle breakpoints */
if (handle_breakpoints)
breakpoint = breakpoint_find(target, current_pc);
- if (breakpoint != NULL) {
+ if (breakpoint) {
retval = arm7_9_unset_breakpoint(target, breakpoint);
if (retval != ERROR_OK)
return retval;
struct reg_cache *t, **cache_p;
t = embeddedice_build_reg_cache(target, arm7_9);
- if (t == NULL)
+ if (!t)
return ERROR_FAIL;
cache_p = register_get_last_cache_p(&target->reg_cache);
return ERROR_COMMAND_SYNTAX_ERROR;
output = fopen(CMD_ARGV[0], "w");
- if (output == NULL) {
+ if (!output) {
LOG_DEBUG("error opening cache content file");
return ERROR_OK;
}
return ERROR_COMMAND_SYNTAX_ERROR;
output = fopen(CMD_ARGV[0], "w");
- if (output == NULL) {
+ if (!output) {
LOG_DEBUG("error opening mmu content file");
return ERROR_OK;
}
uint32_t *read_buf = calloc(count, sizeof(uint32_t));
/* Multiplication count * sizeof(uint32_t) may overflow, calloc() is safe */
uint32_t *read_ptr = read_buf;
- if (read_buf == NULL) {
+ if (!read_buf) {
LOG_ERROR("Failed to allocate read buffer");
return ERROR_FAIL;
}
int e;
pc = (struct adiv5_private_config *)target->private_config;
- if (pc == NULL) {
+ if (!pc) {
pc = calloc(1, sizeof(struct adiv5_private_config));
pc->ap_num = DP_APSEL_INVALID;
target->private_config = pc;
int adiv5_verify_config(struct adiv5_private_config *pc)
{
- if (pc == NULL)
+ if (!pc)
return ERROR_FAIL;
- if (pc->dap == NULL)
+ if (!pc->dap)
return ERROR_FAIL;
return ERROR_OK;
static inline int dap_send_sequence(struct adiv5_dap *dap,
enum swd_special_seq seq)
{
- assert(dap->ops != NULL);
+ assert(dap->ops);
return dap->ops->send_sequence(dap, seq);
}
static inline int dap_queue_dp_read(struct adiv5_dap *dap,
unsigned reg, uint32_t *data)
{
- assert(dap->ops != NULL);
+ assert(dap->ops);
return dap->ops->queue_dp_read(dap, reg, data);
}
static inline int dap_queue_dp_write(struct adiv5_dap *dap,
unsigned reg, uint32_t data)
{
- assert(dap->ops != NULL);
+ assert(dap->ops);
return dap->ops->queue_dp_write(dap, reg, data);
}
*/
static inline int dap_queue_ap_abort(struct adiv5_dap *dap, uint8_t *ack)
{
- assert(dap->ops != NULL);
+ assert(dap->ops);
return dap->ops->queue_ap_abort(dap, ack);
}
*/
static inline int dap_run(struct adiv5_dap *dap)
{
- assert(dap->ops != NULL);
+ assert(dap->ops);
return dap->ops->run(dap);
}
static inline int dap_sync(struct adiv5_dap *dap)
{
- assert(dap->ops != NULL);
+ assert(dap->ops);
if (dap->ops->sync)
return dap->ops->sync(dap);
return ERROR_OK;
{
struct adiv5_ap *ap = dap_ap(self->spot.dap, self->spot.ap_num);
- if (p_value == NULL)
+ if (!p_value)
return ERROR_COMMAND_ARGUMENT_INVALID;
return mem_ap_read_atomic_u32(ap, self->spot.base + reg, p_value);
int e;
cmd_ctx = current_command_context(goi->interp);
- assert(cmd_ctx != NULL);
+ assert(cmd_ctx);
if (goi->argc < 3) {
Jim_WrongNumArgs(goi->interp, 1, goi->argv, "?name? ..options...");
/* Create it */
cti = calloc(1, sizeof(*cti));
- if (cti == NULL)
+ if (!cti)
return JIM_ERR;
adiv5_mem_ap_spot_init(&cti->spot);
if (e != JIM_OK)
return e;
tap = jtag_tap_by_jim_obj(goi->interp, o_t);
- if (tap == NULL) {
+ if (!tap) {
Jim_SetResultString(goi->interp, "-chain-position is invalid", -1);
return JIM_ERR;
}
}
}
- if (tap == NULL) {
+ if (!tap) {
Jim_SetResultString(goi->interp, "-chain-position required when creating DAP", -1);
return JIM_ERR;
}
int e;
cmd_ctx = current_command_context(goi->interp);
- assert(cmd_ctx != NULL);
+ assert(cmd_ctx);
if (goi->argc < 3) {
Jim_WrongNumArgs(goi->interp, 1, goi->argv, "?name? ..options...");
/* Create it */
dap = calloc(1, sizeof(struct arm_dap_object));
- if (dap == NULL)
+ if (!dap)
return JIM_ERR;
e = dap_configure(goi, dap);
struct adiv5_dap *dap = arm->dap;
uint32_t apsel;
- if (dap == NULL) {
+ if (!dap) {
LOG_ERROR("DAP instance not available. Probably a HLA target...");
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
arm->read_core_reg = arm_dpm_read_core_reg;
arm->write_core_reg = arm_dpm_write_core_reg;
- if (arm->core_cache == NULL) {
+ if (!arm->core_cache) {
cache = arm_build_reg_cache(target, arm);
if (!cache)
return ERROR_FAIL;
buf_set_u32(t, 0, field.num_bits, new_instr);
field.in_value = NULL;
- if (no_verify_capture == NULL)
+ if (!no_verify_capture)
jtag_add_ir_scan(tap, &field, end_state);
else {
/* FIX!!!! this is a kludge!!! arm926ejs.c should reimplement this arm_jtag_set_instr to
static int arm_tpiu_swo_configure(struct jim_getopt_info *goi, struct arm_tpiu_swo_object *obj)
{
- assert(obj != NULL);
+ assert(obj);
if (goi->isconfigure && obj->enabled) {
Jim_SetResultFormatted(goi->interp, "Cannot configure TPIU/SWO; %s is enabled!", obj->name);
int e;
cmd_ctx = current_command_context(interp);
- assert(cmd_ctx != NULL);
+ assert(cmd_ctx);
/* does this command exist? */
cmd = Jim_GetCommand(interp, Jim_NewStringObj(interp, obj->name, -1), JIM_ERRMSG);
#if HAVE_CAPSTONE
struct target *target = get_current_target(CMD_CTX);
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("No target selected");
return ERROR_FAIL;
}
int retval;
context = current_command_context(interp);
- assert(context != NULL);
+ assert(context);
target = get_current_target(context);
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("%s: no current target", __func__);
return JIM_ERR;
}
}
}
- if (l2x_cache != NULL)
+ if (l2x_cache)
command_print(cmd, "Outer unified cache Base Address 0x%" PRIx32 ", %" PRIu32 " ways",
l2x_cache->base, l2x_cache->way);
LOG_USER("Page Directory at (phys): %8.8" TARGET_PRIxADDR, ttb);
first_lvl_ptbl = malloc(sizeof(uint32_t)*(max_pt_idx+1));
- if (first_lvl_ptbl == NULL)
+ if (!first_lvl_ptbl)
return ERROR_FAIL;
/*
blocks_to_check = num_blocks;
struct algo_block *params = malloc((blocks_to_check+1)*sizeof(struct algo_block));
- if (params == NULL) {
+ if (!params) {
retval = ERROR_FAIL;
goto cleanup1;
}
return retval;
n = jim_nvp_value2name_simple(nvp_ecatch_modes, edeccr & 0x0f);
- if (n->name != NULL)
+ if (n->name)
sec = n->name;
n = jim_nvp_value2name_simple(nvp_ecatch_modes, edeccr & 0xf0);
- if (n->name != NULL)
+ if (n->name)
nsec = n->name;
if (sec == NULL || nsec == NULL) {
while (CMD_ARGC > argp) {
n = jim_nvp_name2value_simple(nvp_ecatch_modes, CMD_ARGV[argp]);
- if (n->name == NULL) {
+ if (!n->name) {
LOG_ERROR("Unknown option: %s", CMD_ARGV[argp]);
return ERROR_FAIL;
}
struct reg_cache *cache = NULL, *cache32 = NULL;
cache = arm->core_cache;
- if (cache != NULL)
+ if (cache)
cache32 = cache->next;
armv8_free_cache(cache32, true);
armv8_free_cache(cache, false);
arm->read_core_reg = armv8_dpm_read_core_reg;
arm->write_core_reg = armv8_dpm_write_core_reg;
- if (arm->core_cache == NULL) {
+ if (!arm->core_cache) {
cache = armv8_build_reg_cache(target);
if (!cache)
return ERROR_FAIL;
int busy = 0;
tap = jtag_info->tap;
- if (tap == NULL)
+ if (!tap)
return ERROR_FAIL;
if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != (uint32_t)new_instr) {
static int mcu_write_ir(struct jtag_tap *tap, uint8_t *ir_in, uint8_t *ir_out,
int ir_len, int rti)
{
- if (NULL == tap) {
+ if (!tap) {
LOG_ERROR("invalid tap");
return ERROR_FAIL;
}
static int mcu_write_dr(struct jtag_tap *tap, uint8_t *dr_in, uint8_t *dr_out,
int dr_len, int rti)
{
- if (NULL == tap) {
+ if (!tap) {
LOG_ERROR("invalid tap");
return ERROR_FAIL;
}
{
LOG_DEBUG("Delete all breakpoints for target: %s",
target_name(target));
- while (target->breakpoints != NULL)
+ while (target->breakpoints)
breakpoint_free(target, target->breakpoints);
}
{
LOG_DEBUG("Delete all watchpoints for target: %s",
target_name(target));
- while (target->watchpoints != NULL)
+ while (target->watchpoints)
watchpoint_free(target, target->watchpoints);
}
struct cortex_a_common *cortex_a;
struct adiv5_private_config *pc;
- if (target->private_config == NULL)
+ if (!target->private_config)
return ERROR_FAIL;
pc = (struct adiv5_private_config *)target->private_config;
cortex_a = calloc(1, sizeof(struct cortex_a_common));
- if (cortex_a == NULL) {
+ if (!cortex_a) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
return ERROR_FAIL;
cortex_a = calloc(1, sizeof(struct cortex_a_common));
- if (cortex_a == NULL) {
+ if (!cortex_a) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
if (CMD_ARGC > 0) {
n = jim_nvp_name2value_simple(nvp_maskisr_modes, CMD_ARGV[0]);
- if (n->name == NULL) {
+ if (!n->name) {
LOG_ERROR("Unknown parameter: %s - should be off or on", CMD_ARGV[0]);
return ERROR_COMMAND_SYNTAX_ERROR;
}
if (CMD_ARGC > 0) {
n = jim_nvp_name2value_simple(nvp_dacrfixup_modes, CMD_ARGV[0]);
- if (n->name == NULL)
+ if (!n->name)
return ERROR_COMMAND_SYNTAX_ERROR;
cortex_a->dacrfixup_mode = n->value;
return ERROR_FAIL;
struct cortex_m_common *cortex_m = calloc(1, sizeof(struct cortex_m_common));
- if (cortex_m == NULL) {
+ if (!cortex_m) {
LOG_ERROR("No memory creating target");
return ERROR_FAIL;
}
if (CMD_ARGC > 0) {
n = jim_nvp_name2value_simple(nvp_maskisr_modes, CMD_ARGV[0]);
- if (n->name == NULL)
+ if (!n->name)
return ERROR_COMMAND_SYNTAX_ERROR;
cortex_m->isrmasking_mode = n->value;
cortex_m_set_maskints_for_halt(target);
*/
int retval = ERROR_OK;
- if (NULL == target->tap) {
+ if (!target->tap) {
retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_INVALID_TAP,
"Invalid tap");
err_check(retval, DSP5680XX_ERROR_JTAG_DRSCAN,
"drscan failed!");
}
- if (d_out != NULL)
+ if (d_out)
LOG_DEBUG("Data read (%d bits): 0x%04X", len, *d_out);
else
LOG_DEBUG("Data read was discarded.");
uint16_t tap_ir_len = DSP5680XX_JTAG_MASTER_TAP_IRLEN;
- if (NULL == target->tap) {
+ if (!target->tap) {
retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_INVALID_TAP,
"Invalid tap");
} else {
struct jtag_tap *t =
jtag_tap_by_string("dsp568013.chp");
- if ((t == NULL)
+ if ((!t)
|| ((t->enabled) && (ir_len != tap_ir_len))) {
retval = ERROR_FAIL;
err_check(retval,
dsp5680xx_irscan(target, &instr, &read_from_ir,
DSP5680XX_JTAG_CORE_TAP_IRLEN);
err_check_propagate(retval);
- if (status != NULL)
+ if (status)
*status = (uint8_t) read_from_ir;
return ERROR_OK;
}
dsp5680xx_drscan(target, (uint8_t *) &instr,
(uint8_t *) &data_read_dummy, num_bits);
err_check_propagate(retval);
- if (data_read != NULL)
+ if (data_read)
*data_read = data_read_dummy;
return retval;
}
retval = jtag_data_write(target, instr_with_flags, 8, &dr_out_tmp);
err_check_propagate(retval);
- if (eonce_status != NULL)
+ if (eonce_status)
*eonce_status = (uint8_t) dr_out_tmp;
return retval;
}
uint32_t ir_out; /* not used, just to make jtag happy. */
- if (master_tap == NULL) {
+ if (!master_tap) {
master_tap = jtag_tap_by_string("dsp568013.chp");
- if (master_tap == NULL) {
+ if (!master_tap) {
retval = ERROR_FAIL;
const char *msg = "Failed to get master tap.";
msg);
}
}
- if (core_tap == NULL) {
+ if (!core_tap) {
core_tap = jtag_tap_by_string("dsp568013.cpu");
- if (core_tap == NULL) {
+ if (!core_tap) {
retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_TAP_FIND_CORE,
"Failed to get core tap.");
*/
err_check_propagate(retval);
}
- if (eonce_status != NULL)
+ if (eonce_status)
*eonce_status = data_read_from_dr;
return retval;
}
struct jtag_tap *tap_cpu;
tap_chp = jtag_tap_by_string("dsp568013.chp");
- if (tap_chp == NULL) {
+ if (!tap_chp) {
retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_TAP_FIND_MASTER,
"Failed to get master tap.");
}
tap_cpu = jtag_tap_by_string("dsp568013.cpu");
- if (tap_cpu == NULL) {
+ if (!tap_cpu) {
retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_TAP_FIND_CORE,
"Failed to get master tap.");
retval = ERROR_TARGET_FAILURE;
err_check(retval, DSP5680XX_ERROR_ENTER_DEBUG_MODE, msg);
}
- if (eonce_status != NULL)
+ if (eonce_status)
*eonce_status = data_read_from_dr;
return retval;
}
int retval;
check_halt_and_debug(target);
- if (protected == NULL) {
+ if (!protected) {
const char *msg = "NULL pointer not valid.";
err_check(ERROR_FAIL,
retval =
dsp5680xx_f_ex(target, HFM_ERASE_VERIFY, tmp, 0, &hfm_ustat, 1);
err_check_propagate(retval);
- if (erased != NULL)
+ if (erased)
*erased = (uint8_t) (hfm_ustat & HFM_USTAT_MASK_BLANK);
return retval;
}
struct jtag_tap *tap_cpu;
tap_chp = jtag_tap_by_string("dsp568013.chp");
- if (tap_chp == NULL) {
+ if (!tap_chp) {
retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_TAP_ENABLE_MASTER,
"Failed to get master tap.");
}
tap_cpu = jtag_tap_by_string("dsp568013.cpu");
- if (tap_cpu == NULL) {
+ if (!tap_cpu) {
retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_TAP_ENABLE_CORE,
"Failed to get master tap.");
jtag_add_sleep(TIME_DIV_FREESCALE * 300 * 1000);
tap_chp = jtag_tap_by_string("dsp568013.chp");
- if (tap_chp == NULL) {
+ if (!tap_chp) {
retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_TAP_ENABLE_MASTER,
"Failed to get master tap.");
}
tap_cpu = jtag_tap_by_string("dsp568013.cpu");
- if (tap_cpu == NULL) {
+ if (!tap_cpu) {
retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_TAP_ENABLE_CORE,
"Failed to get master tap.");
LOG_DEBUG("-");
- while (breakpoint != NULL) {
+ while (breakpoint) {
if (breakpoint->set == 0)
esirisc_add_breakpoint(target, breakpoint);
LOG_DEBUG("-");
- while (watchpoint != NULL) {
+ while (watchpoint) {
if (watchpoint->set == 0)
esirisc_add_watchpoint(target, watchpoint);
if (handle_breakpoints) {
breakpoint = breakpoint_find(target, address);
- if (breakpoint != NULL)
+ if (breakpoint)
esirisc_remove_breakpoint(target, breakpoint);
}
case EID_INST_BREAKPOINT:
breakpoint = breakpoint_find(target,
buf_get_u32(esirisc->epc->value, 0, esirisc->epc->size));
- target->debug_reason = (breakpoint != NULL) ?
+ target->debug_reason = (breakpoint) ?
DBG_REASON_BREAKPOINT : DBG_REASON_DBGRQ;
break;
struct jtag_tap *tap = target->tap;
struct esirisc_common *esirisc;
- if (tap == NULL)
+ if (!tap)
return ERROR_FAIL;
if (tap->ir_length != INSTR_LENGTH) {
}
esirisc = calloc(1, sizeof(struct esirisc_common));
- if (esirisc == NULL)
+ if (!esirisc)
return ERROR_FAIL;
esirisc->target = target;
size = esirisc_trace_buffer_size(trace_info);
buffer = calloc(1, size);
- if (buffer == NULL) {
+ if (!buffer) {
command_print(cmd, "out of memory");
return ERROR_FAIL;
}
int retval;
buffer = calloc(1, size);
- if (buffer == NULL) {
+ if (!buffer) {
command_print(cmd, "out of memory");
return ERROR_FAIL;
}
size = esirisc_trace_buffer_size(trace_info);
buffer = calloc(1, size);
- if (buffer == NULL) {
+ if (!buffer) {
command_print(cmd, "out of memory");
return ERROR_FAIL;
}
int retval;
buffer = calloc(1, size);
- if (buffer == NULL) {
+ if (!buffer) {
command_print(cmd, "out of memory");
return ERROR_FAIL;
}
struct jtag_tap *tap;
tap = etb->tap;
- if (tap == NULL)
+ if (!tap)
return ERROR_FAIL;
if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != new_instr) {
}
tap = jtag_tap_by_string(CMD_ARGV[1]);
- if (tap == NULL) {
+ if (!tap) {
command_print(CMD, "ETB: TAP %s does not exist", CMD_ARGV[1]);
return ERROR_FAIL;
}
fileio_read_u32(file, &etm_ctx->trace_depth);
}
etm_ctx->trace_data = malloc(sizeof(struct etmv1_trace_data) * etm_ctx->trace_depth);
- if (etm_ctx->trace_data == NULL) {
+ if (!etm_ctx->trace_data) {
command_print(CMD, "not enough memory to perform operation");
fileio_close(file);
return ERROR_FAIL;
}
struct cortex_m_common *cortex_m = calloc(1, sizeof(struct cortex_m_common));
- if (cortex_m == NULL) {
+ if (!cortex_m) {
LOG_ERROR("No memory creating target");
return ERROR_FAIL;
}
static int image_ihex_buffer_complete(struct image *image)
{
char *lpsz_line = malloc(1023);
- if (lpsz_line == NULL) {
+ if (!lpsz_line) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
struct imagesection *section = malloc(sizeof(struct imagesection) * IMAGE_MAX_SECTIONS);
- if (section == NULL) {
+ if (!section) {
free(lpsz_line);
LOG_ERROR("Out of memory");
return ERROR_FAIL;
elf->header32 = malloc(sizeof(Elf32_Ehdr));
- if (elf->header32 == NULL) {
+ if (!elf->header32) {
LOG_ERROR("insufficient memory to perform operation");
return ERROR_FILEIO_OPERATION_FAILED;
}
}
elf->segments32 = malloc(elf->segment_count*sizeof(Elf32_Phdr));
- if (elf->segments32 == NULL) {
+ if (!elf->segments32) {
LOG_ERROR("insufficient memory to perform operation");
return ERROR_FILEIO_OPERATION_FAILED;
}
/* alloc and fill sections array with loadable segments */
image->sections = malloc(image->num_sections * sizeof(struct imagesection));
- if (image->sections == NULL) {
+ if (!image->sections) {
LOG_ERROR("insufficient memory to perform operation");
return ERROR_FILEIO_OPERATION_FAILED;
}
elf->header64 = malloc(sizeof(Elf64_Ehdr));
- if (elf->header64 == NULL) {
+ if (!elf->header64) {
LOG_ERROR("insufficient memory to perform operation");
return ERROR_FILEIO_OPERATION_FAILED;
}
}
elf->segments64 = malloc(elf->segment_count*sizeof(Elf64_Phdr));
- if (elf->segments64 == NULL) {
+ if (!elf->segments64) {
LOG_ERROR("insufficient memory to perform operation");
return ERROR_FILEIO_OPERATION_FAILED;
}
/* alloc and fill sections array with loadable segments */
image->sections = malloc(image->num_sections * sizeof(struct imagesection));
- if (image->sections == NULL) {
+ if (!image->sections) {
LOG_ERROR("insufficient memory to perform operation");
return ERROR_FILEIO_OPERATION_FAILED;
}
static int image_mot_buffer_complete(struct image *image)
{
char *lpsz_line = malloc(1023);
- if (lpsz_line == NULL) {
+ if (!lpsz_line) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
struct imagesection *section = malloc(sizeof(struct imagesection) * IMAGE_MAX_SECTIONS);
- if (section == NULL) {
+ if (!section) {
free(lpsz_line);
LOG_ERROR("Out of memory");
return ERROR_FAIL;
} else if (image->type == IMAGE_MEMORY) {
struct target *target = get_target(url);
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("target '%s' not defined", url);
return ERROR_FAIL;
}
{
int retval = ERROR_OK;
struct x86_32_common *x86_32 = target_to_x86_32(t);
- if (NULL == t->tap) {
+ if (!t->tap) {
retval = ERROR_FAIL;
LOG_ERROR("%s invalid target tap", __func__);
return retval;
int retval = ERROR_OK;
uint64_t data = 0;
struct x86_32_common *x86_32 = target_to_x86_32(t);
- if (NULL == t->tap) {
+ if (!t->tap) {
retval = ERROR_FAIL;
LOG_ERROR("%s invalid target tap", __func__);
return retval;
return retval;
}
}
- if (in != NULL) {
+ if (in) {
if (len >= 8) {
for (int n = (len / 8) - 1 ; n >= 0; n--)
data = (data << 8) + *(in+n);
*/
struct breakpoint *bp = NULL;
bp = breakpoint_find(t, eip-1);
- if (bp != NULL) {
+ if (bp) {
t->debug_reason = DBG_REASON_BREAKPOINT;
if (bp->type == BKPT_SOFT) {
/* The EIP is now pointing the next byte after the
/* prepare resetbreak setting the proper bits in CLTAPC_CPU_VPREQ */
x86_32->curr_tap = jtag_tap_by_position(1);
- if (x86_32->curr_tap == NULL) {
+ if (!x86_32->curr_tap) {
x86_32->curr_tap = saved_tap;
LOG_ERROR("%s could not select quark_x10xx.cltap", __func__);
return ERROR_FAIL;
struct adiv5_private_config *pc;
pc = (struct adiv5_private_config *)target->private_config;
- if (pc == NULL)
+ if (!pc)
return ERROR_FAIL;
if (pc->ap_num == DP_APSEL_INVALID) {
}
mem_ap = calloc(1, sizeof(struct mem_ap));
- if (mem_ap == NULL) {
+ if (!mem_ap) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
} scan_32;
} *scan_in = malloc(sizeof(union scan_in) * (ctx->code_count + ctx->store_count));
- if (scan_in == NULL) {
+ if (!scan_in) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
uint32_t *data = NULL;
if (size != 4) {
data = malloc(256 * sizeof(uint32_t));
- if (data == NULL) {
+ if (!data) {
LOG_ERROR("Out of memory");
goto exit;
}
return ERROR_JTAG_DEVICE_ERROR;
}
- if (ctx->local_iparam == NULL) {
+ if (!ctx->local_iparam) {
LOG_ERROR("Error: unexpected reading of input parameter");
return ERROR_JTAG_DEVICE_ERROR;
}
&& (address < MIPS64_PRACC_PARAM_OUT + ctx->num_oparam * MIPS64_PRACC_DATA_STEP)) {
offset = (address - MIPS64_PRACC_PARAM_OUT) / MIPS64_PRACC_DATA_STEP;
- if (ctx->local_oparam == NULL) {
+ if (!ctx->local_oparam) {
LOG_ERROR("Error: unexpected reading of output parameter");
return ERROR_JTAG_DEVICE_ERROR;
}
if ((address >= MIPS64_PRACC_PARAM_IN)
&& (address < MIPS64_PRACC_PARAM_IN + ctx->num_iparam * MIPS64_PRACC_DATA_STEP)) {
offset = (address - MIPS64_PRACC_PARAM_IN) / MIPS64_PRACC_DATA_STEP;
- if (ctx->local_iparam == NULL) {
+ if (!ctx->local_iparam) {
LOG_ERROR("Error: unexpected writing of input parameter");
return ERROR_JTAG_DEVICE_ERROR;
}
} else if ((address >= MIPS64_PRACC_PARAM_OUT)
&& (address < MIPS64_PRACC_PARAM_OUT + ctx->num_oparam * MIPS64_PRACC_DATA_STEP)) {
offset = (address - MIPS64_PRACC_PARAM_OUT) / MIPS64_PRACC_DATA_STEP;
- if (ctx->local_oparam == NULL) {
+ if (!ctx->local_oparam) {
LOG_ERROR("Error: unexpected writing of output parameter");
return ERROR_JTAG_DEVICE_ERROR;
}
void mips_ejtag_set_instr(struct mips_ejtag *ejtag_info, uint32_t new_instr)
{
- assert(ejtag_info->tap != NULL);
+ assert(ejtag_info->tap);
struct jtag_tap *tap = ejtag_info->tap;
if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != new_instr) {
void mips_ejtag_add_scan_96(struct mips_ejtag *ejtag_info, uint32_t ctrl, uint32_t data, uint8_t *in_scan_buf)
{
- assert(ejtag_info->tap != NULL);
+ assert(ejtag_info->tap);
struct jtag_tap *tap = ejtag_info->tap;
struct scan_field field;
struct jtag_tap *tap;
tap = ejtag_info->tap;
- if (tap == NULL)
+ if (!tap)
return ERROR_FAIL;
struct scan_field field;
uint8_t t[8] = { 0 }, r[8];
static void mips_ejtag_drscan_32_queued(struct mips_ejtag *ejtag_info,
uint32_t data_out, uint8_t *data_in)
{
- assert(ejtag_info->tap != NULL);
+ assert(ejtag_info->tap);
struct jtag_tap *tap = ejtag_info->tap;
struct scan_field field;
int mips_ejtag_drscan_8(struct mips_ejtag *ejtag_info, uint8_t *data)
{
- assert(ejtag_info->tap != NULL);
+ assert(ejtag_info->tap);
struct jtag_tap *tap = ejtag_info->tap;
struct scan_field field;
void mips_ejtag_drscan_8_out(struct mips_ejtag *ejtag_info, uint8_t data)
{
- assert(ejtag_info->tap != NULL);
+ assert(ejtag_info->tap);
struct jtag_tap *tap = ejtag_info->tap;
struct scan_field field;
int mips_ejtag_fastdata_scan(struct mips_ejtag *ejtag_info, int write_t, uint32_t *data)
{
- assert(ejtag_info->tap != NULL);
+ assert(ejtag_info->tap);
struct jtag_tap *tap = ejtag_info->tap;
struct scan_field fields[2];
struct jtag_tap *tap;
tap = ejtag_info->tap;
- assert(tap != NULL);
+ assert(tap);
struct scan_field fields[2];
uint8_t spracc = 0;
if (size > 1) {
t = malloc(count * size * sizeof(uint8_t));
- if (t == NULL) {
+ if (!t) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
/* mips32_..._write_mem with size 4/2 requires uint32_t/uint16_t in host */
/* endianness, but byte array represents target endianness */
t = malloc(count * size * sizeof(uint8_t));
- if (t == NULL) {
+ if (!t) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
if (address & 0x3u)
return ERROR_TARGET_UNALIGNED_ACCESS;
- if (mips32->fast_data_area == NULL) {
+ if (!mips32->fast_data_area) {
/* Get memory for block write handler
* we preserve this area between calls and gain a speed increase
* of about 3kb/sec when writing flash
/* but byte array represents target endianness */
uint32_t *t = NULL;
t = malloc(count * sizeof(uint32_t));
- if (t == NULL) {
+ if (!t) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
LOG_DEBUG("nds32_login");
- if (nds32->edm_passcode != NULL) {
+ if (nds32->edm_passcode) {
/* convert EDM passcode to command sequences */
passcode_length = strlen(nds32->edm_passcode);
command_sequence[0] = '\0';
int nds32_get_gdb_fileio_info(struct target *target, struct gdb_fileio_info *fileio_info)
{
/* fill syscall parameters to file-I/O info */
- if (NULL == fileio_info) {
+ if (!fileio_info) {
LOG_ERROR("Target has not initial file-I/O data structure");
return ERROR_FAIL;
}
/** Convert target handle to generic Andes target state handle. */
static inline struct nds32 *target_to_nds32(struct target *target)
{
- assert(target != NULL);
+ assert(target);
return target->arch_info;
}
/** */
static inline struct aice_port_s *target_to_aice(struct target *target)
{
- assert(target != NULL);
+ assert(target);
return target->tap->priv;
}
static inline bool is_nds32(struct nds32 *nds32)
{
- assert(nds32 != NULL);
+ assert(nds32);
return nds32->common_magic == NDS32_COMMON_MAGIC;
}
static inline bool nds32_reach_max_interrupt_level(struct nds32 *nds32)
{
- assert(nds32 != NULL);
+ assert(nds32);
return nds32->max_interrupt_level == nds32->current_interrupt_level;
}
return e;
uint32_t *data = malloc(count * sizeof(uint32_t));
- if (data == NULL)
+ if (!data)
return JIM_ERR;
jim_wide i;
struct or1k_du *du_core = or1k_to_du(or1k);
struct or1k_jtag *jtag = &or1k->jtag;
- if (du_core == NULL) {
+ if (!du_core) {
LOG_ERROR("No debug unit selected");
return ERROR_FAIL;
}
- if (jtag->tap_ip == NULL) {
+ if (!jtag->tap_ip) {
LOG_ERROR("No tap selected");
return ERROR_FAIL;
}
static int or1k_target_create(struct target *target, Jim_Interp *interp)
{
- if (target->tap == NULL)
+ if (!target->tap)
return ERROR_FAIL;
struct or1k_common *or1k = calloc(1, sizeof(struct or1k_common));
struct target *target = jtag_info->target;
if ((target->endianness == TARGET_BIG_ENDIAN) && (size != 1)) {
t = malloc(count * size * sizeof(uint8_t));
- if (t == NULL) {
+ if (!t) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
static int quark_d20xx_target_create(struct target *t, Jim_Interp *interp)
{
struct x86_32_common *x86_32 = calloc(1, sizeof(struct x86_32_common));
- if (x86_32 == NULL) {
+ if (!x86_32) {
LOG_ERROR("%s out of memory", __func__);
return ERROR_FAIL;
}
if (debug_level < LOG_LVL_DEBUG)
return;
- assert(field->out_value != NULL);
+ assert(field->out_value);
uint64_t out = buf_get_u64(field->out_value, 0, field->num_bits);
unsigned int out_op = get_field(out, DTM_DMI_OP);
unsigned int out_data = get_field(out, DTM_DMI_DATA);
{
RISCV_INFO(r);
LOG_DEBUG("handle_breakpoints=%d", handle_breakpoints);
- if (r->is_halted == NULL)
+ if (!r->is_halted)
return oldriscv_step(target, current, address, handle_breakpoints);
else
return riscv_openocd_step(target, current, address, handle_breakpoints);
LOG_DEBUG(" version=0x%x", info->dtm_version);
struct target_type *tt = get_target_type(target);
- if (tt == NULL)
+ if (!tt)
return ERROR_FAIL;
int result = tt->init_target(info->cmd_ctx, target);
static int old_or_new_riscv_poll(struct target *target)
{
RISCV_INFO(r);
- if (r->is_halted == NULL)
+ if (!r->is_halted)
return oldriscv_poll(target);
else
return riscv_openocd_poll(target);
{
riscv_info_t *r = riscv_info(target);
int result;
- if (r->is_halted == NULL) {
+ if (!r->is_halted) {
struct target_type *tt = get_target_type(target);
result = tt->halt(target);
} else {
{
RISCV_INFO(r);
- if (r->is_halted == NULL) {
+ if (!r->is_halted) {
struct target_type *tt = get_target_type(target);
return tt->halt(target);
}
{
riscv_info_t *r = riscv_info(target);
int result;
- if (r->is_halted == NULL) {
+ if (!r->is_halted) {
struct target_type *tt = get_target_type(target);
result = tt->resume(target, current, address, handle_breakpoints,
debug_execution);
int riscv_count_harts(struct target *target)
{
- if (target == NULL)
+ if (!target)
return 1;
RISCV_INFO(r);
if (r == NULL || r->hart_count == NULL)
LOG_DEBUG(" ");
target->fileio_info = malloc(sizeof(*target->fileio_info));
- if (target->fileio_info == NULL) {
+ if (!target->fileio_info) {
LOG_ERROR("out of memory");
return ERROR_FAIL;
}
struct semihosting *semihosting;
semihosting = malloc(sizeof(*target->semihosting));
- if (semihosting == NULL) {
+ if (!semihosting) {
LOG_ERROR("out of memory");
return ERROR_FAIL;
}
{
struct target *target = get_current_target(CMD_CTX);
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("No target selected");
return ERROR_FAIL;
}
{
struct target *target = get_current_target(CMD_CTX);
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("No target selected");
return ERROR_FAIL;
}
struct target *target = get_current_target(CMD_CTX);
unsigned int i;
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("No target selected");
return ERROR_FAIL;
}
for (i = 1; i < CMD_ARGC; i++) {
char *cmdline = alloc_printf("%s %s", semihosting->cmdline, CMD_ARGV[i]);
- if (cmdline == NULL)
+ if (!cmdline)
break;
free(semihosting->cmdline);
semihosting->cmdline = cmdline;
{
struct target *target = get_current_target(CMD_CTX);
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("No target selected");
return ERROR_FAIL;
}
#include "server/server.h"
#define foreach_smp_target(pos, head) \
- for (pos = head; (pos != NULL); pos = pos->next)
+ for (pos = head; (pos); pos = pos->next)
extern const struct command_registration smp_command_handlers[];
const struct jim_nvp *n;
n = jim_nvp_value2name_simple(nvp_error_target, err);
- if (n->name == NULL)
+ if (!n->name)
return "unknown";
else
return n->name;
{
struct target *target = get_current_target_or_null(cmd_ctx);
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("BUG: current_target out of bounds");
exit(-1);
}
int retval;
struct jim_nvp *n;
n = jim_nvp_value2name_simple(nvp_reset_modes, reset_mode);
- if (n->name == NULL) {
+ if (!n->name) {
LOG_ERROR("invalid reset mode");
return ERROR_FAIL;
}
target_reset_examined(target);
struct target_type *type = target->type;
- if (type->examine == NULL)
+ if (!type->examine)
type->examine = default_examine;
- if (type->check_reset == NULL)
+ if (!type->check_reset)
type->check_reset = default_check_reset;
- assert(type->init_target != NULL);
+ assert(type->init_target);
int retval = type->init_target(cmd_ctx, target);
if (retval != ERROR_OK) {
* implement it in stages, but warn if we need to do so.
*/
if (type->mmu) {
- if (type->virt2phys == NULL) {
+ if (!type->virt2phys) {
LOG_ERROR("type '%s' is missing virt2phys", type->name);
type->virt2phys = identity_virt2phys;
}
{
struct target_event_callback **callbacks_p = &target_event_callbacks;
- if (callback == NULL)
+ if (!callback)
return ERROR_COMMAND_SYNTAX_ERROR;
if (*callbacks_p) {
{
struct target_reset_callback *entry;
- if (callback == NULL)
+ if (!callback)
return ERROR_COMMAND_SYNTAX_ERROR;
entry = malloc(sizeof(struct target_reset_callback));
- if (entry == NULL) {
+ if (!entry) {
LOG_ERROR("error allocating buffer for reset callback entry");
return ERROR_COMMAND_SYNTAX_ERROR;
}
{
struct target_trace_callback *entry;
- if (callback == NULL)
+ if (!callback)
return ERROR_COMMAND_SYNTAX_ERROR;
entry = malloc(sizeof(struct target_trace_callback));
- if (entry == NULL) {
+ if (!entry) {
LOG_ERROR("error allocating buffer for trace callback entry");
return ERROR_COMMAND_SYNTAX_ERROR;
}
{
struct target_timer_callback **callbacks_p = &target_timer_callbacks;
- if (callback == NULL)
+ if (!callback)
return ERROR_COMMAND_SYNTAX_ERROR;
if (*callbacks_p) {
struct target_event_callback **p = &target_event_callbacks;
struct target_event_callback *c = target_event_callbacks;
- if (callback == NULL)
+ if (!callback)
return ERROR_COMMAND_SYNTAX_ERROR;
while (c) {
{
struct target_reset_callback *entry;
- if (callback == NULL)
+ if (!callback)
return ERROR_COMMAND_SYNTAX_ERROR;
list_for_each_entry(entry, &target_reset_callback_list, list) {
{
struct target_trace_callback *entry;
- if (callback == NULL)
+ if (!callback)
return ERROR_COMMAND_SYNTAX_ERROR;
list_for_each_entry(entry, &target_trace_callback_list, list) {
int target_unregister_timer_callback(int (*callback)(void *priv), void *priv)
{
- if (callback == NULL)
+ if (!callback)
return ERROR_COMMAND_SYNTAX_ERROR;
for (struct target_timer_callback *c = target_timer_callbacks;
if (size < area->size) {
struct working_area *new_wa = malloc(sizeof(*new_wa));
- if (new_wa == NULL)
+ if (!new_wa)
return;
new_wa->next = area->next;
int target_alloc_working_area_try(struct target *target, uint32_t size, struct working_area **area)
{
/* Reevaluate working area address based on MMU state*/
- if (target->working_areas == NULL) {
+ if (!target->working_areas) {
int retval;
int enabled;
c = c->next;
}
- if (c == NULL)
+ if (!c)
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
/* Split the working area into the requested size */
size, c->address);
if (target->backup_working_area) {
- if (c->backup == NULL) {
+ if (!c->backup) {
c->backup = malloc(c->size);
- if (c->backup == NULL)
+ if (!c->backup)
return ERROR_FAIL;
}
struct working_area *c = target->working_areas;
uint32_t max_size = 0;
- if (c == NULL)
+ if (!c)
return target->working_area_size;
while (c) {
/* release the targets SMP list */
if (target->smp) {
struct target_list *head = target->head;
- while (head != NULL) {
+ while (head) {
struct target_list *pos = head->next;
head->target->smp = 0;
free(head);
int target_arch_state(struct target *target)
{
int retval;
- if (target == NULL) {
+ if (!target) {
LOG_WARNING("No target has been configured");
return ERROR_OK;
}
retval = target->type->checksum_memory(target, address, size, &checksum);
if (retval != ERROR_OK) {
buffer = malloc(size);
- if (buffer == NULL) {
+ if (!buffer) {
LOG_ERROR("error allocating buffer for section (%" PRIu32 " bytes)", size);
return ERROR_COMMAND_SYNTAX_ERROR;
}
static int find_target(struct command_invocation *cmd, const char *name)
{
struct target *target = get_target(name);
- if (target == NULL) {
+ if (!target) {
command_print(cmd, "Target: %s is unknown, try one of:\n", name);
return ERROR_FAIL;
}
goto not_found;
}
- assert(reg != NULL); /* give clang a hint that we *know* reg is != NULL here */
+ assert(reg); /* give clang a hint that we *know* reg is != NULL here */
if (!reg->exist)
goto not_found;
/* set register value */
if (CMD_ARGC == 2) {
uint8_t *buf = malloc(DIV_ROUND_UP(reg->size, 8));
- if (buf == NULL)
+ if (!buf)
return ERROR_FAIL;
str_to_buf(CMD_ARGV[1], strlen(CMD_ARGV[1]), buf, reg->size, 0);
if (CMD_ARGC == 1) {
const struct jim_nvp *n;
n = jim_nvp_name2value_simple(nvp_reset_modes, CMD_ARGV[0]);
- if ((n->name == NULL) || (n->value == RESET_UNKNOWN))
+ if ((!n->name) || (n->value == RESET_UNKNOWN))
return ERROR_COMMAND_SYNTAX_ERROR;
reset_mode = n->value;
}
COMMAND_PARSE_NUMBER(uint, CMD_ARGV[1], count);
uint8_t *buffer = calloc(count, size);
- if (buffer == NULL) {
+ if (!buffer) {
LOG_ERROR("Failed to allocate md read buffer");
return ERROR_FAIL;
}
* to fill large memory areas with any sane speed */
const unsigned chunk_size = 16384;
uint8_t *target_buf = malloc(chunk_size * data_size);
- if (target_buf == NULL) {
+ if (!target_buf) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
retval = ERROR_OK;
for (unsigned int i = 0; i < image.num_sections; i++) {
buffer = malloc(image.sections[i].size);
- if (buffer == NULL) {
+ if (!buffer) {
command_print(CMD,
"error allocating buffer for section (%d bytes)",
(int)(image.sections[i].size));
retval = ERROR_OK;
for (unsigned int i = 0; i < image.num_sections; i++) {
buffer = malloc(image.sections[i].size);
- if (buffer == NULL) {
+ if (!buffer) {
command_print(CMD,
"error allocating buffer for section (%" PRIu32 " bytes)",
image.sections[i].size);
{
uint32_t i;
FILE *f = fopen(filename, "w");
- if (f == NULL)
+ if (!f)
return;
write_string(f, "gmon");
write_long(f, 0x00000001, target); /* Version */
if (num_buckets > max_buckets)
num_buckets = max_buckets;
int *buckets = malloc(sizeof(int) * num_buckets);
- if (buckets == NULL) {
+ if (!buckets) {
fclose(f);
return;
}
/*append binary memory gmon.out profile_hist_data (profile_hist_data + profile_hist_hdr.hist_size) */
char *data = malloc(2 * num_buckets);
- if (data != NULL) {
+ if (data) {
for (i = 0; i < num_buckets; i++) {
int val;
val = buckets[i];
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], offset);
uint32_t *samples = malloc(sizeof(uint32_t) * MAX_PROFILE_SAMPLE_NUM);
- if (samples == NULL) {
+ if (!samples) {
LOG_ERROR("No memory to store samples.");
return ERROR_FAIL;
}
struct target *target;
context = current_command_context(interp);
- assert(context != NULL);
+ assert(context);
target = get_current_target(context);
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("mem2array: no current target");
return JIM_ERR;
}
const size_t buffersize = 4096;
uint8_t *buffer = malloc(buffersize);
- if (buffer == NULL)
+ if (!buffer)
return JIM_ERR;
/* assume ok */
Jim_Obj *obj_val = Jim_GetVariable(interp, obj_name, JIM_ERRMSG);
Jim_DecrRefCount(interp, obj_name);
free(namebuf);
- if (obj_val == NULL)
+ if (!obj_val)
return JIM_ERR;
jim_wide wide_val;
struct target *target;
context = current_command_context(interp);
- assert(context != NULL);
+ assert(context);
target = get_current_target(context);
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("array2mem: no current target");
return JIM_ERR;
}
const size_t buffersize = 4096;
uint8_t *buffer = malloc(buffersize);
- if (buffer == NULL)
+ if (!buffer)
return JIM_ERR;
/* index counter */
/* END_DEPRECATED_TPIU */
bool replace = true;
- if (teap == NULL) {
+ if (!teap) {
/* create new */
teap = calloc(1, sizeof(*teap));
replace = false;
Jim_SetEmptyResult(goi->interp);
} else {
/* get */
- if (teap == NULL)
+ if (!teap)
Jim_SetEmptyResult(goi->interp);
else
Jim_SetResult(goi->interp, Jim_DuplicateObj(goi->interp, teap->body));
goto no_params;
}
n = jim_nvp_value2name_simple(nvp_target_endian, target->endianness);
- if (n->name == NULL) {
+ if (!n->name) {
target->endianness = TARGET_LITTLE_ENDIAN;
n = jim_nvp_value2name_simple(nvp_target_endian, target->endianness);
}
if (e != JIM_OK)
return e;
tap = jtag_tap_by_jim_obj(goi->interp, o_t);
- if (tap == NULL)
+ if (!tap)
return JIM_ERR;
target->tap = tap;
target->tap_configured = true;
struct command_context *cmd_ctx;
cmd_ctx = current_command_context(goi->interp);
- assert(cmd_ctx != NULL);
+ assert(cmd_ctx);
if (goi->argc < 3) {
Jim_WrongNumArgs(goi->interp, 1, goi->argv, "?name? ?type? ..options...");
}
}
/* tap must be set after target was configured */
- if (target->tap == NULL)
+ if (!target->tap)
e = JIM_ERR;
}
return JIM_ERR;
}
struct command_context *cmd_ctx = current_command_context(interp);
- assert(cmd_ctx != NULL);
+ assert(cmd_ctx);
struct target *target = get_current_target_or_null(cmd_ctx);
if (target)
static void free_fastload(void)
{
- if (fastload != NULL) {
+ if (fastload) {
for (int i = 0; i < fastload_num; i++)
free(fastload[i].data);
free(fastload);
retval = ERROR_OK;
fastload_num = image.num_sections;
fastload = malloc(sizeof(struct fast_load)*image.num_sections);
- if (fastload == NULL) {
+ if (!fastload) {
command_print(CMD, "out of memory");
image_close(&image);
return ERROR_FAIL;
memset(fastload, 0, sizeof(struct fast_load)*image.num_sections);
for (unsigned int i = 0; i < image.num_sections; i++) {
buffer = malloc(image.sections[i].size);
- if (buffer == NULL) {
+ if (!buffer) {
command_print(CMD, "error allocating buffer for section (%d bytes)",
(int)(image.sections[i].size));
retval = ERROR_FAIL;
{
if (CMD_ARGC > 0)
return ERROR_COMMAND_SYNTAX_ERROR;
- if (fastload == NULL) {
+ if (!fastload) {
LOG_ERROR("No image in memory");
return ERROR_FAIL;
}
static void binprint(struct command_invocation *cmd, const char *text, const uint8_t *buf, int size)
{
- if (text != NULL)
+ if (text)
command_print_sameline(cmd, "%s", text);
for (int i = 0; i < size; i++)
command_print_sameline(cmd, " %02x", buf[i]);
out:
free(test_pattern);
- if (wa != NULL)
+ if (wa)
target_free_working_area(target, wa);
/* Test writes */
free(test_pattern);
- if (wa != NULL)
+ if (wa)
target_free_working_area(target, wa);
return retval;
}
{
struct debug_msg_receiver **p = &target->dbgmsg;
- if (target == NULL)
+ if (!target)
return ERROR_COMMAND_SYNTAX_ERROR;
/* see if there's already a list */
int do_all_targets = 0;
/* if no target has been specified search all of them */
- if (target == NULL) {
+ if (!target) {
/* if no targets haven been specified */
- if (all_targets == NULL)
+ if (!all_targets)
return NULL;
target = all_targets;
int do_all_targets = 0;
/* if no target has been specified search all of them */
- if (target == NULL) {
+ if (!target) {
/* if no targets haven been specified */
- if (all_targets == NULL)
+ if (!all_targets)
return ERROR_OK;
target = all_targets;
x86_32->num_hw_bpoints = MAX_DEBUG_REGS;
x86_32->hw_break_list = calloc(x86_32->num_hw_bpoints,
sizeof(struct x86_32_dbg_reg));
- if (x86_32->hw_break_list == NULL) {
+ if (!x86_32->hw_break_list) {
LOG_ERROR("%s out of memory", __func__);
return ERROR_FAIL;
}
* with the original instructions again.
*/
struct swbp_mem_patch *iter = x86_32->swbbp_mem_patch_list;
- while (iter != NULL) {
+ while (iter) {
if (iter->physaddr >= phys_address && iter->physaddr < phys_address+(size*count)) {
uint32_t offset = iter->physaddr - phys_address;
buffer[offset] = iter->orig_byte;
* breakpoint instruction.
*/
newbuffer = malloc(size*count);
- if (newbuffer == NULL) {
+ if (!newbuffer) {
LOG_ERROR("%s out of memory", __func__);
return ERROR_FAIL;
}
memcpy(newbuffer, buffer, size*count);
struct swbp_mem_patch *iter = x86_32->swbbp_mem_patch_list;
- while (iter != NULL) {
+ while (iter) {
if (iter->physaddr >= phys_address && iter->physaddr < phys_address+(size*count)) {
uint32_t offset = iter->physaddr - phys_address;
newbuffer[offset] = SW_BP_OPCODE;
/* add the memory patch */
struct swbp_mem_patch *new_patch = malloc(sizeof(struct swbp_mem_patch));
- if (new_patch == NULL) {
+ if (!new_patch) {
LOG_ERROR("%s out of memory", __func__);
return ERROR_FAIL;
}
new_patch->swbp_unique_id = bp->unique_id;
struct swbp_mem_patch *addto = x86_32->swbbp_mem_patch_list;
- if (addto == NULL)
+ if (!addto)
x86_32->swbbp_mem_patch_list = new_patch;
else {
- while (addto->next != NULL)
+ while (addto->next)
addto = addto->next;
addto->next = new_patch;
}
/* remove from patch */
struct swbp_mem_patch *iter = x86_32->swbbp_mem_patch_list;
- if (iter != NULL) {
+ if (iter) {
if (iter->swbp_unique_id == bp->unique_id) {
/* it's the first item */
x86_32->swbbp_mem_patch_list = iter->next;
} else {
while (iter->next != NULL && iter->next->swbp_unique_id != bp->unique_id)
iter = iter->next;
- if (iter->next != NULL) {
+ if (iter->next) {
/* it's the next one */
struct swbp_mem_patch *freeme = iter->next;
iter->next = iter->next->next;
static int xscale_jtag_set_instr(struct jtag_tap *tap, uint32_t new_instr, tap_state_t end_state)
{
- assert(tap != NULL);
+ assert(tap);
if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != new_instr) {
struct scan_field field;
struct breakpoint *breakpoint;
breakpoint = breakpoint_find(target,
buf_get_u32(arm->pc->value, 0, 32));
- if (breakpoint != NULL) {
+ if (breakpoint) {
uint32_t next_pc;
enum trace_mode saved_trace_mode;
if (handle_breakpoints)
breakpoint = breakpoint_find(target,
buf_get_u32(arm->pc->value, 0, 32));
- if (breakpoint != NULL) {
+ if (breakpoint) {
retval = xscale_unset_breakpoint(target, breakpoint);
if (retval != ERROR_OK)
return retval;
return ERROR_COMMAND_SYNTAX_ERROR;
target = get_target(CMD_ARGV[0]);
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("target '%s' not defined", CMD_ARGV[0]);
return ERROR_FAIL;
}
return ERROR_COMMAND_SYNTAX_ERROR;
target = get_target(CMD_ARGV[0]);
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("target '%s' not defined", CMD_ARGV[0]);
return ERROR_FAIL;
}
/* our return vector must be NULL terminated */
argv = calloc(n + 1, sizeof(char *));
- if (argv == NULL)
+ if (!argv)
return ERROR_FAIL;
for (unsigned i = 0; i < n; i++) {
field.out_value = dr_out_buf;
field.in_value = calloc(DIV_ROUND_UP(field.num_bits, 8), 1);
- if (tap == NULL)
+ if (!tap)
jtag_add_plain_dr_scan(field.num_bits,
field.out_value,
field.in_value,
field.in_value = NULL;
- if (tap == NULL)
+ if (!tap)
jtag_add_plain_ir_scan(field.num_bits,
field.out_value, field.in_value, my_end_state);
else
if (attempt > 0 && verbose)
LOG_USER("LSDR retry %d", attempt);
- if (tap == NULL)
+ if (!tap)
jtag_add_plain_dr_scan(field.num_bits,
field.out_value,
field.in_value,