/* force "set" to 0/1 */
set = !!set;
- if (bank->driver->protect == NULL) {
+ if (!bank->driver->protect) {
LOG_ERROR("Flash protection is not supported.");
return ERROR_FLASH_OPER_UNSUPPORTED;
}
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++) {
return ERROR_FLASH_DST_BREAKS_ALIGNMENT;
}
- if (c->prot_blocks == NULL || c->num_prot_blocks == 0) {
+ if (!c->prot_blocks || c->num_prot_blocks == 0) {
/* flash driver does not define protect blocks, use sectors instead */
iterate_protect_blocks = false;
}
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++) {