aboutsummaryrefslogtreecommitdiff
path: root/src/target
diff options
context:
space:
mode:
Diffstat (limited to 'src/target')
-rw-r--r--src/target/aarch64.c28
-rw-r--r--src/target/adi_v5_jtag.c20
-rw-r--r--src/target/adi_v5_swd.c2
-rw-r--r--src/target/arc.c8
-rw-r--r--src/target/arm.h4
-rw-r--r--src/target/arm11.c2
-rw-r--r--src/target/arm11_dbgtap.c2
-rw-r--r--src/target/arm7_9_common.c6
-rw-r--r--src/target/arm920t.c4
-rw-r--r--src/target/arm_adi_v5.c8
-rw-r--r--src/target/arm_adi_v5.h12
-rw-r--r--src/target/arm_cti.c6
-rw-r--r--src/target/arm_dap.c10
-rw-r--r--src/target/arm_dpm.c2
-rw-r--r--src/target/arm_jtag.c2
-rw-r--r--src/target/arm_tpiu_swo.c4
-rw-r--r--src/target/armv4_5.c6
-rw-r--r--src/target/armv7a.c2
-rw-r--r--src/target/armv7a_mmu.c2
-rw-r--r--src/target/armv7m.c2
-rw-r--r--src/target/armv8.c8
-rw-r--r--src/target/armv8_dpm.c2
-rw-r--r--src/target/avr32_jtag.c2
-rw-r--r--src/target/avrt.c4
-rw-r--r--src/target/breakpoints.c4
-rw-r--r--src/target/cortex_a.c10
-rw-r--r--src/target/cortex_m.c4
-rw-r--r--src/target/dsp5680xx.c42
-rw-r--r--src/target/esirisc.c12
-rw-r--r--src/target/esirisc_trace.c8
-rw-r--r--src/target/etb.c4
-rw-r--r--src/target/etm.c2
-rw-r--r--src/target/hla_target.c2
-rw-r--r--src/target/image.c22
-rw-r--r--src/target/lakemont.c10
-rw-r--r--src/target/mem_ap.c4
-rw-r--r--src/target/mips32_pracc.c4
-rw-r--r--src/target/mips64_pracc.c8
-rw-r--r--src/target/mips_ejtag.c16
-rw-r--r--src/target/mips_m4k.c8
-rw-r--r--src/target/nds32.c4
-rw-r--r--src/target/nds32.h8
-rw-r--r--src/target/nds32_cmd.c2
-rw-r--r--src/target/openrisc/or1k.c6
-rw-r--r--src/target/openrisc/or1k_du_adv.c2
-rw-r--r--src/target/quark_d20xx.c2
-rw-r--r--src/target/riscv/batch.c2
-rw-r--r--src/target/riscv/riscv.c14
-rw-r--r--src/target/semihosting_common.c14
-rw-r--r--src/target/smp.h2
-rw-r--r--src/target/target.c118
-rw-r--r--src/target/target_request.c10
-rw-r--r--src/target/x86_32_common.c18
-rw-r--r--src/target/xscale.c10
54 files changed, 260 insertions, 260 deletions
diff --git a/src/target/aarch64.c b/src/target/aarch64.c
index 87c6bce..43a13aa 100644
--- a/src/target/aarch64.c
+++ b/src/target/aarch64.c
@@ -335,7 +335,7 @@ static int aarch64_prepare_halt_smp(struct target *target, bool exc_target, stru
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;
@@ -359,7 +359,7 @@ static int aarch64_prepare_halt_smp(struct target *target, bool exc_target, stru
LOG_DEBUG("target %s prepared", target_name(curr));
- if (first == NULL)
+ if (!first)
first = curr;
}
@@ -488,7 +488,7 @@ static int update_halt_gdb(struct target *target, enum target_debug_reason debug
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)
@@ -762,7 +762,7 @@ static int aarch64_prep_restart_smp(struct target *target, int handle_breakpoint
break;
}
/* remember the first valid target in the group */
- if (first == NULL)
+ if (!first)
first = curr;
}
@@ -785,7 +785,7 @@ static int aarch64_step_restart_smp(struct target *target)
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));
@@ -2548,7 +2548,7 @@ static int aarch64_examine_first(struct target *target)
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) {
@@ -2634,7 +2634,7 @@ static int aarch64_examine_first(struct target *target)
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;
@@ -2739,7 +2739,7 @@ static int aarch64_target_create(struct target *target, Jim_Interp *interp)
return ERROR_FAIL;
aarch64 = calloc(1, sizeof(struct aarch64_common));
- if (aarch64 == NULL) {
+ if (!aarch64) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
@@ -2797,7 +2797,7 @@ static int aarch64_jim_configure(struct target *target, struct jim_getopt_info *
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;
@@ -2842,7 +2842,7 @@ static int aarch64_jim_configure(struct target *target, struct jim_getopt_info *
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;
}
@@ -2896,7 +2896,7 @@ COMMAND_HANDLER(aarch64_handle_disassemble_command)
{
struct target *target = get_current_target(CMD_CTX);
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("No target selected");
return ERROR_FAIL;
}
@@ -2939,7 +2939,7 @@ COMMAND_HANDLER(aarch64_mask_interrupts_command)
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;
}
@@ -2971,10 +2971,10 @@ static int jim_mcrmrc(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
}
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;
}
diff --git a/src/target/adi_v5_jtag.c b/src/target/adi_v5_jtag.c
index 29bc04f..998c51c 100644
--- a/src/target/adi_v5_jtag.c
+++ b/src/target/adi_v5_jtag.c
@@ -179,7 +179,7 @@ static struct dap_cmd *dap_cmd_new(struct adiv5_dap *dap, uint8_t instr,
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);
@@ -194,9 +194,9 @@ static struct dap_cmd *dap_cmd_new(struct adiv5_dap *dap, uint8_t instr,
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;
@@ -255,7 +255,7 @@ static int adi_jtag_dp_scan_cmd(struct adiv5_dap *dap, struct dap_cmd *cmd, uint
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.
@@ -323,7 +323,7 @@ static int adi_jtag_dp_scan(struct adiv5_dap *dap,
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;
@@ -367,7 +367,7 @@ static int adi_jtag_finish_read(struct adiv5_dap *dap)
{
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;
@@ -391,7 +391,7 @@ static int adi_jtag_scan_inout_check_u32(struct adiv5_dap *dap,
/* 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)
@@ -453,7 +453,7 @@ static int jtagdp_overrun_check(struct adiv5_dap *dap)
}
}
- if (prev != NULL) {
+ if (prev) {
log_dap_cmd("LST", el);
/*
@@ -466,7 +466,7 @@ static int jtagdp_overrun_check(struct adiv5_dap *dap)
*/
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;
}
@@ -545,7 +545,7 @@ static int jtagdp_overrun_check(struct adiv5_dap *dap)
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;
}
diff --git a/src/target/adi_v5_swd.c b/src/target/adi_v5_swd.c
index f1fca40..a21bf25 100644
--- a/src/target/adi_v5_swd.c
+++ b/src/target/adi_v5_swd.c
@@ -58,7 +58,7 @@ static bool do_sync;
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;
}
diff --git a/src/target/arc.c b/src/target/arc.c
index 77c9090..1e8a515 100644
--- a/src/target/arc.c
+++ b/src/target/arc.c
@@ -931,8 +931,8 @@ exit:
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 */
@@ -981,7 +981,7 @@ static int arc_examine_debug_reason(struct target *target)
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.");
@@ -1940,7 +1940,7 @@ static int arc_hit_watchpoint(struct target *target, struct watchpoint **hit_wat
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.");
diff --git a/src/target/arm.h b/src/target/arm.h
index 2f35734..1732789 100644
--- a/src/target/arm.h
+++ b/src/target/arm.h
@@ -252,13 +252,13 @@ struct arm {
/** 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;
}
diff --git a/src/target/arm11.c b/src/target/arm11.c
index 81409cb..e3b0975 100644
--- a/src/target/arm11.c
+++ b/src/target/arm11.c
@@ -1096,7 +1096,7 @@ static int arm11_target_create(struct target *target, Jim_Interp *interp)
{
struct arm11_common *arm11;
- if (target->tap == NULL)
+ if (!target->tap)
return ERROR_FAIL;
if (target->tap->ir_length != 5) {
diff --git a/src/target/arm11_dbgtap.c b/src/target/arm11_dbgtap.c
index 0200647..fc35414 100644
--- a/src/target/arm11_dbgtap.c
+++ b/src/target/arm11_dbgtap.c
@@ -586,7 +586,7 @@ static int arm11_run_instr_data_to_core_noack_inner(struct jtag_tap *tap,
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;
}
diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c
index 36ca5b9..cf77a81 100644
--- a/src/target/arm7_9_common.c
+++ b/src/target/arm7_9_common.c
@@ -1740,7 +1740,7 @@ int arm7_9_resume(struct target *target,
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);
@@ -1932,7 +1932,7 @@ int arm7_9_step(struct target *target, int current, target_addr_t address, int h
/* 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;
@@ -2675,7 +2675,7 @@ int arm7_9_examine(struct target *target)
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);
diff --git a/src/target/arm920t.c b/src/target/arm920t.c
index c8842da..a6d626e 100644
--- a/src/target/arm920t.c
+++ b/src/target/arm920t.c
@@ -887,7 +887,7 @@ COMMAND_HANDLER(arm920t_handle_read_cache_command)
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;
}
@@ -1169,7 +1169,7 @@ COMMAND_HANDLER(arm920t_handle_read_mmu_command)
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;
}
diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c
index 65ac053..c458ffd 100644
--- a/src/target/arm_adi_v5.c
+++ b/src/target/arm_adi_v5.c
@@ -505,7 +505,7 @@ static int mem_ap_read(struct adiv5_ap *ap, uint8_t *buffer, uint32_t size, uint
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;
}
@@ -1653,7 +1653,7 @@ int adiv5_jim_configure(struct target *target, struct jim_getopt_info *goi)
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;
@@ -1681,10 +1681,10 @@ int adiv5_jim_configure(struct target *target, struct jim_getopt_info *goi)
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;
diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h
index 7eb44f2..8ebe963 100644
--- a/src/target/arm_adi_v5.h
+++ b/src/target/arm_adi_v5.h
@@ -392,7 +392,7 @@ static inline bool is_64bit_ap(struct adiv5_ap *ap)
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);
}
@@ -411,7 +411,7 @@ static inline int dap_send_sequence(struct adiv5_dap *dap,
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);
}
@@ -429,7 +429,7 @@ static inline int dap_queue_dp_read(struct adiv5_dap *dap,
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);
}
@@ -479,7 +479,7 @@ static inline int dap_queue_ap_write(struct adiv5_ap *ap,
*/
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);
}
@@ -495,13 +495,13 @@ static inline int dap_queue_ap_abort(struct adiv5_dap *dap, uint8_t *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;
diff --git a/src/target/arm_cti.c b/src/target/arm_cti.c
index c168245..7d005e2 100644
--- a/src/target/arm_cti.c
+++ b/src/target/arm_cti.c
@@ -143,7 +143,7 @@ int arm_cti_read_reg(struct arm_cti *self, unsigned int reg, uint32_t *p_value)
{
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);
@@ -456,7 +456,7 @@ static int cti_create(struct jim_getopt_info *goi)
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...");
@@ -474,7 +474,7 @@ static int cti_create(struct jim_getopt_info *goi)
/* Create it */
cti = calloc(1, sizeof(*cti));
- if (cti == NULL)
+ if (!cti)
return JIM_ERR;
adiv5_mem_ap_spot_init(&cti->spot);
diff --git a/src/target/arm_dap.c b/src/target/arm_dap.c
index 68297b9..a399c51 100644
--- a/src/target/arm_dap.c
+++ b/src/target/arm_dap.c
@@ -187,7 +187,7 @@ static int dap_configure(struct jim_getopt_info *goi, struct arm_dap_object *dap
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;
}
@@ -202,7 +202,7 @@ static int dap_configure(struct jim_getopt_info *goi, struct arm_dap_object *dap
}
}
- if (tap == NULL) {
+ if (!tap) {
Jim_SetResultString(goi->interp, "-chain-position required when creating DAP", -1);
return JIM_ERR;
}
@@ -223,7 +223,7 @@ static int dap_create(struct jim_getopt_info *goi)
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...");
@@ -241,7 +241,7 @@ static int dap_create(struct jim_getopt_info *goi)
/* Create it */
dap = calloc(1, sizeof(struct arm_dap_object));
- if (dap == NULL)
+ if (!dap)
return JIM_ERR;
e = dap_configure(goi, dap);
@@ -317,7 +317,7 @@ COMMAND_HANDLER(handle_dap_info_command)
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;
}
diff --git a/src/target/arm_dpm.c b/src/target/arm_dpm.c
index 276e90d..3e55e2e 100644
--- a/src/target/arm_dpm.c
+++ b/src/target/arm_dpm.c
@@ -1070,7 +1070,7 @@ int arm_dpm_setup(struct arm_dpm *dpm)
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;
diff --git a/src/target/arm_jtag.c b/src/target/arm_jtag.c
index f9605ac..6a27e32 100644
--- a/src/target/arm_jtag.c
+++ b/src/target/arm_jtag.c
@@ -40,7 +40,7 @@ int arm_jtag_set_instr_inner(struct jtag_tap *tap,
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
diff --git a/src/target/arm_tpiu_swo.c b/src/target/arm_tpiu_swo.c
index 66fd748..746ab39 100644
--- a/src/target/arm_tpiu_swo.c
+++ b/src/target/arm_tpiu_swo.c
@@ -351,7 +351,7 @@ static const struct jim_nvp nvp_arm_tpiu_swo_bool_opts[] = {
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);
@@ -866,7 +866,7 @@ static int arm_tpiu_swo_create(Jim_Interp *interp, struct arm_tpiu_swo_object *o
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);
diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c
index 636cb18..b861cf5 100644
--- a/src/target/armv4_5.c
+++ b/src/target/armv4_5.c
@@ -949,7 +949,7 @@ COMMAND_HANDLER(handle_arm_disassemble_command)
#if HAVE_CAPSTONE
struct target *target = get_current_target(CMD_CTX);
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("No target selected");
return ERROR_FAIL;
}
@@ -1007,10 +1007,10 @@ static int jim_mcrmrc(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
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;
}
diff --git a/src/target/armv7a.c b/src/target/armv7a.c
index 98baaf1..cc8c19a 100644
--- a/src/target/armv7a.c
+++ b/src/target/armv7a.c
@@ -282,7 +282,7 @@ int armv7a_handle_cache_info_command(struct command_invocation *cmd,
}
}
- 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);
diff --git a/src/target/armv7a_mmu.c b/src/target/armv7a_mmu.c
index b4234b2..98a0065 100644
--- a/src/target/armv7a_mmu.c
+++ b/src/target/armv7a_mmu.c
@@ -245,7 +245,7 @@ COMMAND_HANDLER(armv7a_mmu_dump_table)
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;
/*
diff --git a/src/target/armv7m.c b/src/target/armv7m.c
index a9a5a38..ee05e47 100644
--- a/src/target/armv7m.c
+++ b/src/target/armv7m.c
@@ -967,7 +967,7 @@ int armv7m_blank_check_memory(struct target *target,
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;
}
diff --git a/src/target/armv8.c b/src/target/armv8.c
index 49e8b10..86c0ebf 100644
--- a/src/target/armv8.c
+++ b/src/target/armv8.c
@@ -1046,11 +1046,11 @@ COMMAND_HANDLER(armv8_handle_exception_catch_command)
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) {
@@ -1064,7 +1064,7 @@ COMMAND_HANDLER(armv8_handle_exception_catch_command)
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;
}
@@ -1730,7 +1730,7 @@ void armv8_free_reg_cache(struct target *target)
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);
diff --git a/src/target/armv8_dpm.c b/src/target/armv8_dpm.c
index c9206ac..188e588 100644
--- a/src/target/armv8_dpm.c
+++ b/src/target/armv8_dpm.c
@@ -1410,7 +1410,7 @@ int armv8_dpm_setup(struct arm_dpm *dpm)
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;
diff --git a/src/target/avr32_jtag.c b/src/target/avr32_jtag.c
index 62c8f98..a23ddf7 100644
--- a/src/target/avr32_jtag.c
+++ b/src/target/avr32_jtag.c
@@ -29,7 +29,7 @@ static int avr32_jtag_set_instr(struct avr32_jtag *jtag_info, int new_instr)
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) {
diff --git a/src/target/avrt.c b/src/target/avrt.c
index eb8d000..feceec6 100644
--- a/src/target/avrt.c
+++ b/src/target/avrt.c
@@ -160,7 +160,7 @@ int avr_jtag_sendinstr(struct jtag_tap *tap, uint8_t *ir_in, uint8_t ir_out)
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;
}
@@ -179,7 +179,7 @@ static int mcu_write_ir(struct jtag_tap *tap, uint8_t *ir_in, uint8_t *ir_out,
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;
}
diff --git a/src/target/breakpoints.c b/src/target/breakpoints.c
index dc8f3c5..4ba9d6b 100644
--- a/src/target/breakpoints.c
+++ b/src/target/breakpoints.c
@@ -377,7 +377,7 @@ static void breakpoint_clear_target_internal(struct target *target)
{
LOG_DEBUG("Delete all breakpoints for target: %s",
target_name(target));
- while (target->breakpoints != NULL)
+ while (target->breakpoints)
breakpoint_free(target, target->breakpoints);
}
@@ -517,7 +517,7 @@ void watchpoint_clear_target(struct target *target)
{
LOG_DEBUG("Delete all watchpoints for target: %s",
target_name(target));
- while (target->watchpoints != NULL)
+ while (target->watchpoints)
watchpoint_free(target, target->watchpoints);
}
diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c
index faed2d5..f41f39d 100644
--- a/src/target/cortex_a.c
+++ b/src/target/cortex_a.c
@@ -3126,13 +3126,13 @@ static int cortex_a_target_create(struct target *target, Jim_Interp *interp)
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;
}
@@ -3153,7 +3153,7 @@ static int cortex_r4_target_create(struct target *target, Jim_Interp *interp)
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;
}
@@ -3268,7 +3268,7 @@ COMMAND_HANDLER(handle_cortex_a_mask_interrupts_command)
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;
}
@@ -3296,7 +3296,7 @@ COMMAND_HANDLER(handle_cortex_a_dacrfixup_command)
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;
diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c
index bd68fe8..9f035a0 100644
--- a/src/target/cortex_m.c
+++ b/src/target/cortex_m.c
@@ -2318,7 +2318,7 @@ static int cortex_m_target_create(struct target *target, Jim_Interp *interp)
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;
}
@@ -2465,7 +2465,7 @@ COMMAND_HANDLER(handle_cortex_m_mask_interrupts_command)
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);
diff --git a/src/target/dsp5680xx.c b/src/target/dsp5680xx.c
index 71bf6f1..939b09d 100644
--- a/src/target/dsp5680xx.c
+++ b/src/target/dsp5680xx.c
@@ -85,7 +85,7 @@ static int dsp5680xx_drscan(struct target *target, uint8_t *d_in,
*/
int retval = ERROR_OK;
- if (NULL == target->tap) {
+ if (!target->tap) {
retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_INVALID_TAP,
"Invalid tap");
@@ -104,7 +104,7 @@ static int dsp5680xx_drscan(struct target *target, uint8_t *d_in,
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.");
@@ -127,7 +127,7 @@ static int dsp5680xx_irscan(struct target *target, uint32_t *d_in,
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");
@@ -140,7 +140,7 @@ static int dsp5680xx_irscan(struct target *target, uint32_t *d_in,
} 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,
@@ -172,7 +172,7 @@ static int dsp5680xx_jtag_status(struct target *target, uint8_t *status)
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;
}
@@ -205,7 +205,7 @@ static int jtag_data_write(struct target *target, uint32_t instr, int num_bits,
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;
}
@@ -239,7 +239,7 @@ static int eonce_instruction_exec_single(struct target *target, uint8_t instr,
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;
}
@@ -577,9 +577,9 @@ static int switch_tap(struct target *target, struct jtag_tap *master_tap,
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.";
@@ -587,9 +587,9 @@ static int switch_tap(struct target *target, struct jtag_tap *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.");
@@ -695,7 +695,7 @@ static int eonce_enter_debug_mode_without_reset(struct target *target,
*/
err_check_propagate(retval);
}
- if (eonce_status != NULL)
+ if (eonce_status)
*eonce_status = data_read_from_dr;
return retval;
}
@@ -731,13 +731,13 @@ static int eonce_enter_debug_mode(struct target *target,
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.");
@@ -833,7 +833,7 @@ static int eonce_enter_debug_mode(struct target *target,
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;
}
@@ -1585,7 +1585,7 @@ int dsp5680xx_f_protect_check(struct target *target, uint16_t *protected)
int retval;
check_halt_and_debug(target);
- if (protected == NULL) {
+ if (!protected) {
const char *msg = "NULL pointer not valid.";
err_check(ERROR_FAIL,
@@ -1829,7 +1829,7 @@ int dsp5680xx_f_erase_check(struct target *target, uint8_t *erased,
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;
}
@@ -2118,13 +2118,13 @@ int dsp5680xx_f_unlock(struct target *target)
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.");
@@ -2226,13 +2226,13 @@ int dsp5680xx_f_lock(struct target *target)
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.");
diff --git a/src/target/esirisc.c b/src/target/esirisc.c
index 9476b0f..d17e1dd 100644
--- a/src/target/esirisc.c
+++ b/src/target/esirisc.c
@@ -539,7 +539,7 @@ static int esirisc_add_breakpoints(struct target *target)
LOG_DEBUG("-");
- while (breakpoint != NULL) {
+ while (breakpoint) {
if (breakpoint->set == 0)
esirisc_add_breakpoint(target, breakpoint);
@@ -723,7 +723,7 @@ static int esirisc_add_watchpoints(struct target *target)
LOG_DEBUG("-");
- while (watchpoint != NULL) {
+ while (watchpoint) {
if (watchpoint->set == 0)
esirisc_add_watchpoint(target, watchpoint);
@@ -890,7 +890,7 @@ static int esirisc_resume_or_step(struct target *target, int current, target_add
if (handle_breakpoints) {
breakpoint = breakpoint_find(target, address);
- if (breakpoint != NULL)
+ if (breakpoint)
esirisc_remove_breakpoint(target, breakpoint);
}
@@ -1061,7 +1061,7 @@ static int esirisc_debug_entry(struct target *target)
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;
@@ -1561,7 +1561,7 @@ static int esirisc_target_create(struct target *target, Jim_Interp *interp)
struct jtag_tap *tap = target->tap;
struct esirisc_common *esirisc;
- if (tap == NULL)
+ if (!tap)
return ERROR_FAIL;
if (tap->ir_length != INSTR_LENGTH) {
@@ -1571,7 +1571,7 @@ static int esirisc_target_create(struct target *target, Jim_Interp *interp)
}
esirisc = calloc(1, sizeof(struct esirisc_common));
- if (esirisc == NULL)
+ if (!esirisc)
return ERROR_FAIL;
esirisc->target = target;
diff --git a/src/target/esirisc_trace.c b/src/target/esirisc_trace.c
index 28d7536..d17a65d 100644
--- a/src/target/esirisc_trace.c
+++ b/src/target/esirisc_trace.c
@@ -551,7 +551,7 @@ static int esirisc_trace_analyze_buffer(struct command_invocation *cmd)
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;
}
@@ -576,7 +576,7 @@ static int esirisc_trace_analyze_memory(struct command_invocation *cmd,
int retval;
buffer = calloc(1, size);
- if (buffer == NULL) {
+ if (!buffer) {
command_print(cmd, "out of memory");
return ERROR_FAIL;
}
@@ -628,7 +628,7 @@ static int esirisc_trace_dump_buffer(struct command_invocation *cmd, const char
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;
}
@@ -653,7 +653,7 @@ static int esirisc_trace_dump_memory(struct command_invocation *cmd, const char
int retval;
buffer = calloc(1, size);
- if (buffer == NULL) {
+ if (!buffer) {
command_print(cmd, "out of memory");
return ERROR_FAIL;
}
diff --git a/src/target/etb.c b/src/target/etb.c
index 0c03c4d..ce1bef9 100644
--- a/src/target/etb.c
+++ b/src/target/etb.c
@@ -44,7 +44,7 @@ static int etb_set_instr(struct etb *etb, uint32_t new_instr)
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) {
@@ -349,7 +349,7 @@ COMMAND_HANDLER(handle_etb_config_command)
}
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;
}
diff --git a/src/target/etm.c b/src/target/etm.c
index 8555872..05577ea 100644
--- a/src/target/etm.c
+++ b/src/target/etm.c
@@ -1808,7 +1808,7 @@ COMMAND_HANDLER(handle_etm_load_command)
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;
diff --git a/src/target/hla_target.c b/src/target/hla_target.c
index d9de2d3..78ec7e8 100644
--- a/src/target/hla_target.c
+++ b/src/target/hla_target.c
@@ -208,7 +208,7 @@ static int adapter_target_create(struct target *target,
}
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;
}
diff --git a/src/target/image.c b/src/target/image.c
index df07ea3..eafa73e 100644
--- a/src/target/image.c
+++ b/src/target/image.c
@@ -337,12 +337,12 @@ static int image_ihex_buffer_complete_inner(struct image *image,
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;
@@ -374,7 +374,7 @@ static int image_elf32_read_headers(struct image *image)
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;
}
@@ -402,7 +402,7 @@ static int image_elf32_read_headers(struct image *image)
}
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;
}
@@ -454,7 +454,7 @@ static int image_elf32_read_headers(struct image *image)
/* 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;
}
@@ -499,7 +499,7 @@ static int image_elf64_read_headers(struct image *image)
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;
}
@@ -527,7 +527,7 @@ static int image_elf64_read_headers(struct image *image)
}
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;
}
@@ -579,7 +579,7 @@ static int image_elf64_read_headers(struct image *image)
/* 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;
}
@@ -937,12 +937,12 @@ static int image_mot_buffer_complete_inner(struct image *image,
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;
@@ -1018,7 +1018,7 @@ int image_open(struct image *image, const char *url, const char *type_string)
} 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;
}
diff --git a/src/target/lakemont.c b/src/target/lakemont.c
index 31b521b..e3f331d 100644
--- a/src/target/lakemont.c
+++ b/src/target/lakemont.c
@@ -227,7 +227,7 @@ static int irscan(struct target *t, uint8_t *out,
{
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;
@@ -260,7 +260,7 @@ static int drscan(struct target *t, uint8_t *out, uint8_t *in, uint8_t len)
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;
@@ -283,7 +283,7 @@ static int drscan(struct target *t, uint8_t *out, uint8_t *in, uint8_t len)
return retval;
}
}
- if (in != NULL) {
+ if (in) {
if (len >= 8) {
for (int n = (len / 8) - 1 ; n >= 0; n--)
data = (data << 8) + *(in+n);
@@ -940,7 +940,7 @@ int lakemont_poll(struct target *t)
*/
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
@@ -1128,7 +1128,7 @@ static int lakemont_reset_break(struct target *t)
/* 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;
diff --git a/src/target/mem_ap.c b/src/target/mem_ap.c
index 0c3d7f7..424d6e7 100644
--- a/src/target/mem_ap.c
+++ b/src/target/mem_ap.c
@@ -38,7 +38,7 @@ static int mem_ap_target_create(struct target *target, Jim_Interp *interp)
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) {
@@ -47,7 +47,7 @@ static int mem_ap_target_create(struct target *target, Jim_Interp *interp)
}
mem_ap = calloc(1, sizeof(struct mem_ap));
- if (mem_ap == NULL) {
+ if (!mem_ap) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
diff --git a/src/target/mips32_pracc.c b/src/target/mips32_pracc.c
index f8643fa..4a8cfcd 100644
--- a/src/target/mips32_pracc.c
+++ b/src/target/mips32_pracc.c
@@ -373,7 +373,7 @@ int mips32_pracc_queue_exec(struct mips_ejtag *ejtag_info, struct pracc_queue_in
} 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;
}
@@ -483,7 +483,7 @@ int mips32_pracc_read_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size
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;
}
diff --git a/src/target/mips64_pracc.c b/src/target/mips64_pracc.c
index 64abf57..b2af39c 100644
--- a/src/target/mips64_pracc.c
+++ b/src/target/mips64_pracc.c
@@ -79,7 +79,7 @@ static int mips64_pracc_exec_read(struct mips64_pracc_context *ctx, uint64_t add
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;
}
@@ -91,7 +91,7 @@ static int mips64_pracc_exec_read(struct mips64_pracc_context *ctx, uint64_t add
&& (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;
}
@@ -179,7 +179,7 @@ static int mips64_pracc_exec_write(struct mips64_pracc_context *ctx, uint64_t ad
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;
}
@@ -187,7 +187,7 @@ static int mips64_pracc_exec_write(struct mips64_pracc_context *ctx, uint64_t ad
} 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;
}
diff --git a/src/target/mips_ejtag.c b/src/target/mips_ejtag.c
index 09af855..b21a1bd 100644
--- a/src/target/mips_ejtag.c
+++ b/src/target/mips_ejtag.c
@@ -32,7 +32,7 @@
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) {
@@ -68,7 +68,7 @@ static int mips_ejtag_get_impcode(struct mips_ejtag *ejtag_info)
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;
@@ -94,7 +94,7 @@ int mips_ejtag_drscan_64(struct mips_ejtag *ejtag_info, uint64_t *data)
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];
@@ -122,7 +122,7 @@ int mips_ejtag_drscan_64(struct mips_ejtag *ejtag_info, uint64_t *data)
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;
@@ -160,7 +160,7 @@ void mips_ejtag_drscan_32_out(struct mips_ejtag *ejtag_info, uint32_t data)
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;
@@ -181,7 +181,7 @@ int mips_ejtag_drscan_8(struct mips_ejtag *ejtag_info, uint8_t *data)
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;
@@ -421,7 +421,7 @@ int mips_ejtag_init(struct mips_ejtag *ejtag_info)
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];
@@ -530,7 +530,7 @@ int mips64_ejtag_fastdata_scan(struct mips_ejtag *ejtag_info, bool write_t, uint
struct jtag_tap *tap;
tap = ejtag_info->tap;
- assert(tap != NULL);
+ assert(tap);
struct scan_field fields[2];
uint8_t spracc = 0;
diff --git a/src/target/mips_m4k.c b/src/target/mips_m4k.c
index 8fa4309..1a40293 100644
--- a/src/target/mips_m4k.c
+++ b/src/target/mips_m4k.c
@@ -1045,7 +1045,7 @@ static int mips_m4k_read_memory(struct target *target, target_addr_t address,
if (size > 1) {
t = malloc(count * size * sizeof(uint8_t));
- if (t == NULL) {
+ if (!t) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
@@ -1112,7 +1112,7 @@ static int mips_m4k_write_memory(struct target *target, target_addr_t address,
/* 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;
}
@@ -1218,7 +1218,7 @@ static int mips_m4k_bulk_write_memory(struct target *target, target_addr_t addre
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
@@ -1250,7 +1250,7 @@ static int mips_m4k_bulk_write_memory(struct target *target, target_addr_t addre
/* 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;
}
diff --git a/src/target/nds32.c b/src/target/nds32.c
index 4b1d117..ca665ec 100644
--- a/src/target/nds32.c
+++ b/src/target/nds32.c
@@ -1991,7 +1991,7 @@ int nds32_login(struct nds32 *nds32)
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';
@@ -2308,7 +2308,7 @@ int nds32_init(struct nds32 *nds32)
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;
}
diff --git a/src/target/nds32.h b/src/target/nds32.h
index e9b9ee1..c447673 100644
--- a/src/target/nds32.h
+++ b/src/target/nds32.h
@@ -431,26 +431,26 @@ extern int nds32_profiling(struct target *target, uint32_t *samples,
/** 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;
}
diff --git a/src/target/nds32_cmd.c b/src/target/nds32_cmd.c
index af1f8b1..9c7d055 100644
--- a/src/target/nds32_cmd.c
+++ b/src/target/nds32_cmd.c
@@ -701,7 +701,7 @@ static int jim_nds32_bulk_write(Jim_Interp *interp, int argc, Jim_Obj * const *a
return e;
uint32_t *data = malloc(count * sizeof(uint32_t));
- if (data == NULL)
+ if (!data)
return JIM_ERR;
jim_wide i;
diff --git a/src/target/openrisc/or1k.c b/src/target/openrisc/or1k.c
index 5b8d7de..8fbcd96 100644
--- a/src/target/openrisc/or1k.c
+++ b/src/target/openrisc/or1k.c
@@ -1089,12 +1089,12 @@ static int or1k_init_target(struct command_context *cmd_ctx,
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;
}
@@ -1111,7 +1111,7 @@ static int or1k_init_target(struct command_context *cmd_ctx,
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));
diff --git a/src/target/openrisc/or1k_du_adv.c b/src/target/openrisc/or1k_du_adv.c
index 31b2487..885fcb9 100644
--- a/src/target/openrisc/or1k_du_adv.c
+++ b/src/target/openrisc/or1k_du_adv.c
@@ -946,7 +946,7 @@ static int or1k_adv_jtag_write_memory(struct or1k_jtag *jtag_info,
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;
}
diff --git a/src/target/quark_d20xx.c b/src/target/quark_d20xx.c
index 9169379..211245d 100644
--- a/src/target/quark_d20xx.c
+++ b/src/target/quark_d20xx.c
@@ -46,7 +46,7 @@
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;
}
diff --git a/src/target/riscv/batch.c b/src/target/riscv/batch.c
index 43f2ffb..3c062e1 100644
--- a/src/target/riscv/batch.c
+++ b/src/target/riscv/batch.c
@@ -183,7 +183,7 @@ void dump_field(int idle, const struct scan_field *field)
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);
diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c
index 4b0bac5..74d59d2 100644
--- a/src/target/riscv/riscv.c
+++ b/src/target/riscv/riscv.c
@@ -951,7 +951,7 @@ static int old_or_new_riscv_step(struct target *target, int current,
{
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);
@@ -975,7 +975,7 @@ static int riscv_examine(struct target *target)
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);
@@ -994,7 +994,7 @@ static int oldriscv_poll(struct target *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);
@@ -1049,7 +1049,7 @@ int halt_go(struct target *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 {
@@ -1071,7 +1071,7 @@ int riscv_halt(struct target *target)
{
RISCV_INFO(r);
- if (r->is_halted == NULL) {
+ if (!r->is_halted) {
struct target_type *tt = get_target_type(target);
return tt->halt(target);
}
@@ -1297,7 +1297,7 @@ static int resume_go(struct target *target, int current,
{
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);
@@ -3056,7 +3056,7 @@ void riscv_set_rtos_hartid(struct target *target, int hartid)
int riscv_count_harts(struct target *target)
{
- if (target == NULL)
+ if (!target)
return 1;
RISCV_INFO(r);
if (r == NULL || r->hart_count == NULL)
diff --git a/src/target/semihosting_common.c b/src/target/semihosting_common.c
index ffed735..fa63903 100644
--- a/src/target/semihosting_common.c
+++ b/src/target/semihosting_common.c
@@ -99,7 +99,7 @@ int semihosting_common_init(struct target *target, void *setup,
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;
}
@@ -107,7 +107,7 @@ int semihosting_common_init(struct target *target, void *setup,
struct semihosting *semihosting;
semihosting = malloc(sizeof(*target->semihosting));
- if (semihosting == NULL) {
+ if (!semihosting) {
LOG_ERROR("out of memory");
return ERROR_FAIL;
}
@@ -1478,7 +1478,7 @@ static __COMMAND_HANDLER(handle_common_semihosting_command)
{
struct target *target = get_current_target(CMD_CTX);
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("No target selected");
return ERROR_FAIL;
}
@@ -1519,7 +1519,7 @@ static __COMMAND_HANDLER(handle_common_semihosting_fileio_command)
{
struct target *target = get_current_target(CMD_CTX);
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("No target selected");
return ERROR_FAIL;
}
@@ -1550,7 +1550,7 @@ static __COMMAND_HANDLER(handle_common_semihosting_cmdline)
struct target *target = get_current_target(CMD_CTX);
unsigned int i;
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("No target selected");
return ERROR_FAIL;
}
@@ -1566,7 +1566,7 @@ static __COMMAND_HANDLER(handle_common_semihosting_cmdline)
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;
@@ -1582,7 +1582,7 @@ static __COMMAND_HANDLER(handle_common_semihosting_resumable_exit_command)
{
struct target *target = get_current_target(CMD_CTX);
- if (target == NULL) {
+ if (!target) {
LOG_ERROR("No target selected");
return ERROR_FAIL;
}
diff --git a/src/target/smp.h b/src/target/smp.h
index f024b40..3338240 100644
--- a/src/target/smp.h
+++ b/src/target/smp.h
@@ -22,7 +22,7 @@
#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[];
diff --git a/src/target/target.c b/src/target/target.c
index 4d2c646..9a476cb 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -188,7 +188,7 @@ static const char *target_strerror_safe(int err)
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;
@@ -526,7 +526,7 @@ struct target *get_current_target(struct command_context *cmd_ctx)
{
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);
}
@@ -663,7 +663,7 @@ static int target_process_reset(struct command_invocation *cmd, enum target_rese
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;
}
@@ -1537,13 +1537,13 @@ static int target_init_one(struct command_context *cmd_ctx,
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) {
@@ -1555,7 +1555,7 @@ static int target_init_one(struct command_context *cmd_ctx,
* 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;
}
@@ -1652,7 +1652,7 @@ int target_register_event_callback(int (*callback)(struct target *target,
{
struct target_event_callback **callbacks_p = &target_event_callbacks;
- if (callback == NULL)
+ if (!callback)
return ERROR_COMMAND_SYNTAX_ERROR;
if (*callbacks_p) {
@@ -1674,11 +1674,11 @@ int target_register_reset_callback(int (*callback)(struct target *target,
{
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;
}
@@ -1696,11 +1696,11 @@ int target_register_trace_callback(int (*callback)(struct target *target,
{
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;
}
@@ -1718,7 +1718,7 @@ int target_register_timer_callback(int (*callback)(void *priv),
{
struct target_timer_callback **callbacks_p = &target_timer_callbacks;
- if (callback == NULL)
+ if (!callback)
return ERROR_COMMAND_SYNTAX_ERROR;
if (*callbacks_p) {
@@ -1748,7 +1748,7 @@ int target_unregister_event_callback(int (*callback)(struct target *target,
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) {
@@ -1770,7 +1770,7 @@ int target_unregister_reset_callback(int (*callback)(struct target *target,
{
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) {
@@ -1789,7 +1789,7 @@ int target_unregister_trace_callback(int (*callback)(struct target *target,
{
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) {
@@ -1805,7 +1805,7 @@ int target_unregister_trace_callback(int (*callback)(struct target *target,
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;
@@ -1961,7 +1961,7 @@ static void target_split_working_area(struct working_area *area, uint32_t size)
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;
@@ -2013,7 +2013,7 @@ static void target_merge_working_areas(struct target *target)
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;
@@ -2072,7 +2072,7 @@ int target_alloc_working_area_try(struct target *target, uint32_t size, struct w
c = c->next;
}
- if (c == NULL)
+ if (!c)
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
/* Split the working area into the requested size */
@@ -2082,9 +2082,9 @@ int target_alloc_working_area_try(struct target *target, uint32_t size, struct w
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;
}
@@ -2215,7 +2215,7 @@ uint32_t target_get_working_area_avail(struct target *target)
struct working_area *c = target->working_areas;
uint32_t max_size = 0;
- if (c == NULL)
+ if (!c)
return target->working_area_size;
while (c) {
@@ -2250,7 +2250,7 @@ static void target_destroy(struct target *target)
/* 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);
@@ -2301,7 +2301,7 @@ void target_quit(void)
int target_arch_state(struct target *target)
{
int retval;
- if (target == NULL) {
+ if (!target) {
LOG_WARNING("No target has been configured");
return ERROR_OK;
}
@@ -2520,7 +2520,7 @@ int target_checksum_memory(struct target *target, target_addr_t address, uint32_
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;
}
@@ -2820,7 +2820,7 @@ int target_write_phys_u8(struct target *target, target_addr_t address, uint8_t v
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;
}
@@ -3136,7 +3136,7 @@ COMMAND_HANDLER(handle_reg_command)
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;
@@ -3163,7 +3163,7 @@ COMMAND_HANDLER(handle_reg_command)
/* 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);
@@ -3316,7 +3316,7 @@ COMMAND_HANDLER(handle_reset_command)
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;
}
@@ -3475,7 +3475,7 @@ COMMAND_HANDLER(handle_md_command)
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;
}
@@ -3506,7 +3506,7 @@ static int target_fill_mem(struct target *target,
* 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;
}
@@ -3654,7 +3654,7 @@ COMMAND_HANDLER(handle_load_image_command)
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));
@@ -3825,7 +3825,7 @@ static COMMAND_HELPER(handle_verify_image_command_internal, enum verify_mode ver
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);
@@ -4194,7 +4194,7 @@ static void write_gmon(uint32_t *samples, uint32_t sample_num, const char *filen
{
uint32_t i;
FILE *f = fopen(filename, "w");
- if (f == NULL)
+ if (!f)
return;
write_string(f, "gmon");
write_long(f, 0x00000001, target); /* Version */
@@ -4236,7 +4236,7 @@ static void write_gmon(uint32_t *samples, uint32_t sample_num, const char *filen
if (num_buckets > max_buckets)
num_buckets = max_buckets;
int *buckets = malloc(sizeof(int) * num_buckets);
- if (buckets == NULL) {
+ if (!buckets) {
fclose(f);
return;
}
@@ -4268,7 +4268,7 @@ static void write_gmon(uint32_t *samples, uint32_t sample_num, const char *filen
/*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];
@@ -4304,7 +4304,7 @@ COMMAND_HANDLER(handle_profile_command)
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;
}
@@ -4406,10 +4406,10 @@ static int jim_mem2array(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
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;
}
@@ -4517,7 +4517,7 @@ static int target_mem2array(Jim_Interp *interp, struct target *target, int argc,
const size_t buffersize = 4096;
uint8_t *buffer = malloc(buffersize);
- if (buffer == NULL)
+ if (!buffer)
return JIM_ERR;
/* assume ok */
@@ -4589,7 +4589,7 @@ static int get_u64_array_element(Jim_Interp *interp, const char *varname, size_t
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;
@@ -4604,10 +4604,10 @@ static int jim_array2mem(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
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;
}
@@ -4720,7 +4720,7 @@ static int target_array2mem(Jim_Interp *interp, struct target *target,
const size_t buffersize = 4096;
uint8_t *buffer = malloc(buffersize);
- if (buffer == NULL)
+ if (!buffer)
return JIM_ERR;
/* index counter */
@@ -4974,7 +4974,7 @@ no_params:
/* END_DEPRECATED_TPIU */
bool replace = true;
- if (teap == NULL) {
+ if (!teap) {
/* create new */
teap = calloc(1, sizeof(*teap));
replace = false;
@@ -5005,7 +5005,7 @@ no_params:
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));
@@ -5091,7 +5091,7 @@ no_params:
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);
}
@@ -5129,7 +5129,7 @@ no_params:
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;
@@ -5692,7 +5692,7 @@ static int target_create(struct jim_getopt_info *goi)
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...");
@@ -5824,7 +5824,7 @@ static int target_create(struct jim_getopt_info *goi)
}
}
/* tap must be set after target was configured */
- if (target->tap == NULL)
+ if (!target->tap)
e = JIM_ERR;
}
@@ -5922,7 +5922,7 @@ static int jim_target_current(Jim_Interp *interp, int argc, Jim_Obj *const *argv
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)
@@ -6081,7 +6081,7 @@ static struct fast_load *fastload;
static void free_fastload(void)
{
- if (fastload != NULL) {
+ if (fastload) {
for (int i = 0; i < fastload_num; i++)
free(fastload[i].data);
free(fastload);
@@ -6115,7 +6115,7 @@ COMMAND_HANDLER(handle_fast_load_image_command)
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;
@@ -6123,7 +6123,7 @@ COMMAND_HANDLER(handle_fast_load_image_command)
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;
@@ -6195,7 +6195,7 @@ COMMAND_HANDLER(handle_fast_load_command)
{
if (CMD_ARGC > 0)
return ERROR_COMMAND_SYNTAX_ERROR;
- if (fastload == NULL) {
+ if (!fastload) {
LOG_ERROR("No image in memory");
return ERROR_FAIL;
}
@@ -6281,7 +6281,7 @@ COMMAND_HANDLER(handle_ps_command)
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]);
@@ -6381,7 +6381,7 @@ next:
out:
free(test_pattern);
- if (wa != NULL)
+ if (wa)
target_free_working_area(target, wa);
/* Test writes */
@@ -6466,7 +6466,7 @@ nextw:
free(test_pattern);
- if (wa != NULL)
+ if (wa)
target_free_working_area(target, wa);
return retval;
}
diff --git a/src/target/target_request.c b/src/target/target_request.c
index 32a9072..cf588f4 100644
--- a/src/target/target_request.c
+++ b/src/target/target_request.c
@@ -158,7 +158,7 @@ static int add_debug_msg_receiver(struct command_context *cmd_ctx, struct target
{
struct debug_msg_receiver **p = &target->dbgmsg;
- if (target == NULL)
+ if (!target)
return ERROR_COMMAND_SYNTAX_ERROR;
/* see if there's already a list */
@@ -186,9 +186,9 @@ static struct debug_msg_receiver *find_debug_msg_receiver(struct command_context
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;
@@ -217,9 +217,9 @@ int delete_debug_msg_receiver(struct command_context *cmd_ctx, struct target *ta
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;
diff --git a/src/target/x86_32_common.c b/src/target/x86_32_common.c
index b7dff23..0d1518c 100644
--- a/src/target/x86_32_common.c
+++ b/src/target/x86_32_common.c
@@ -95,7 +95,7 @@ int x86_32_common_init_arch_info(struct target *t, struct x86_32_common *x86_32)
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;
}
@@ -157,7 +157,7 @@ int x86_32_common_read_phys_mem(struct target *t, target_addr_t phys_address,
* 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;
@@ -245,13 +245,13 @@ int x86_32_common_write_phys_mem(struct target *t, target_addr_t phys_address,
* 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;
@@ -1059,7 +1059,7 @@ static int set_swbp(struct target *t, struct breakpoint *bp)
/* 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;
}
@@ -1069,10 +1069,10 @@ static int set_swbp(struct target *t, struct breakpoint *bp)
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;
}
@@ -1107,7 +1107,7 @@ static int unset_swbp(struct target *t, struct breakpoint *bp)
/* 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;
@@ -1115,7 +1115,7 @@ static int unset_swbp(struct target *t, struct breakpoint *bp)
} 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;
diff --git a/src/target/xscale.c b/src/target/xscale.c
index b25999d..dd383b6 100644
--- a/src/target/xscale.c
+++ b/src/target/xscale.c
@@ -150,7 +150,7 @@ static int xscale_verify_pointer(struct command_invocation *cmd,
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;
@@ -1158,7 +1158,7 @@ static int xscale_resume(struct target *target, int current,
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;
@@ -1421,7 +1421,7 @@ static int xscale_step(struct target *target, int current,
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;
@@ -3048,7 +3048,7 @@ COMMAND_HANDLER(xscale_handle_debug_handler_command)
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;
}
@@ -3083,7 +3083,7 @@ COMMAND_HANDLER(xscale_handle_cache_clean_address_command)
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;
}