aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/jtag/drivers/jlink.c2
-rw-r--r--src/rtos/linux.c13
-rw-r--r--src/rtos/rtos.c4
-rw-r--r--src/server/gdb_server.c8
-rw-r--r--src/target/armv7a.c2
-rw-r--r--src/target/armv7a_cache.c2
-rw-r--r--src/target/armv7a_cache_l2x.c2
-rw-r--r--src/target/armv8_cache.c2
-rw-r--r--src/target/breakpoints.c12
-rw-r--r--src/target/cortex_a.c6
-rw-r--r--src/target/mips_m4k.c6
-rw-r--r--src/target/smp.c2
-rw-r--r--src/target/target.c4
13 files changed, 33 insertions, 32 deletions
diff --git a/src/jtag/drivers/jlink.c b/src/jtag/drivers/jlink.c
index 63bcda1..319ca38 100644
--- a/src/jtag/drivers/jlink.c
+++ b/src/jtag/drivers/jlink.c
@@ -573,7 +573,7 @@ static int jlink_open_device(uint32_t ifaces, bool *found_device)
return ERROR_JTAG_INIT_FAILED;
}
- use_usb_location = (jtag_usb_get_location() != NULL);
+ use_usb_location = !!jtag_usb_get_location();
if (!use_serial_number && !use_usb_address && !use_usb_location && num_devices > 1) {
LOG_ERROR("Multiple devices found, specify the desired device");
diff --git a/src/rtos/linux.c b/src/rtos/linux.c
index 11a55c4..84b4c65 100644
--- a/src/rtos/linux.c
+++ b/src/rtos/linux.c
@@ -195,13 +195,12 @@ static int linux_os_thread_reg_list(struct rtos *rtos,
found = 0;
do {
if (head->target->coreid == next->core_id) {
-
target = head->target;
found = 1;
- } else
- head = head->next;
-
- } while ((head != (struct target_list *)NULL) && (found == 0));
+ break;
+ }
+ head = head->next;
+ } while (head);
if (found == 0) {
LOG_ERROR
@@ -414,7 +413,7 @@ static int get_current(struct target *target, int create)
ctt = ctt->next;
}
- while (head != (struct target_list *)NULL) {
+ while (head) {
struct reg **reg_list;
int reg_list_size;
int retval;
@@ -1397,7 +1396,7 @@ static int linux_os_smp_init(struct target *target)
struct current_thread *ct;
head = target->head;
- while (head != (struct target_list *)NULL) {
+ while (head) {
if (head->target->rtos != rtos) {
struct linux_os *smp_os_linux =
(struct linux_os *)head->target->rtos->rtos_specific_params;
diff --git a/src/rtos/rtos.c b/src/rtos/rtos.c
index 0e747e3..eaad5e5 100644
--- a/src/rtos/rtos.c
+++ b/src/rtos/rtos.c
@@ -234,7 +234,7 @@ int rtos_qsymbol(struct connection *connection, char const *packet, int packet_s
uint64_t addr = 0;
size_t reply_len;
char reply[GDB_BUFFER_SIZE + 1], cur_sym[GDB_BUFFER_SIZE / 2 + 1] = ""; /* Extra byte for null-termination */
- struct symbol_table_elem *next_sym = NULL;
+ struct symbol_table_elem *next_sym;
struct target *target = get_target_from_connection(connection);
struct rtos *os = target->rtos;
@@ -272,7 +272,7 @@ int rtos_qsymbol(struct connection *connection, char const *packet, int packet_s
next_sym = next_symbol(os, cur_sym, addr);
/* Should never happen unless the debugger misbehaves */
- if (next_sym == NULL) {
+ if (!next_sym) {
LOG_WARNING("RTOS: Debugger sent us qSymbol with '%s' that we did not ask for", cur_sym);
goto done;
}
diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index 015baa1..a16b4cc 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -3006,8 +3006,10 @@ static bool gdb_handle_vrun_packet(struct connection *connection, const char *pa
free(next_hex_encoded_field(&parse, ';'));
char *cmdline = next_hex_encoded_field(&parse, ';');
- char *arg;
- while (cmdline && (arg = next_hex_encoded_field(&parse, ';')) != NULL) {
+ while (cmdline) {
+ char *arg = next_hex_encoded_field(&parse, ';');
+ if (!arg)
+ break;
char *new_cmdline = alloc_printf("%s %s", cmdline, arg);
free(cmdline);
free(arg);
@@ -3549,7 +3551,7 @@ static int gdb_target_start(struct target *target, const char *port)
struct target_list *head;
struct target *curr;
head = target->head;
- while (head != (struct target_list *)NULL) {
+ while (head) {
curr = head->target;
if (curr != target)
curr->gdb_service = gdb_service;
diff --git a/src/target/armv7a.c b/src/target/armv7a.c
index 6de79c3..2259fa5 100644
--- a/src/target/armv7a.c
+++ b/src/target/armv7a.c
@@ -207,7 +207,7 @@ static int armv7a_l2x_cache_init(struct target *target, uint32_t base, uint32_t
armv7a->armv7a_mmu.armv7a_cache.outer_cache = l2x_cache;
/* initialize all target in this cluster (smp target)
* l2 cache must be configured after smp declaration */
- while (head != (struct target_list *)NULL) {
+ while (head) {
curr = head->target;
if (curr != target) {
armv7a = target_to_armv7a(curr);
diff --git a/src/target/armv7a_cache.c b/src/target/armv7a_cache.c
index fa6df2a..4078fdd 100644
--- a/src/target/armv7a_cache.c
+++ b/src/target/armv7a_cache.c
@@ -140,7 +140,7 @@ int armv7a_cache_auto_flush_all_data(struct target *target)
struct target_list *head;
struct target *curr;
head = target->head;
- while (head != (struct target_list *)NULL) {
+ while (head) {
curr = head->target;
if (curr->state == TARGET_HALTED)
retval = armv7a_l1_d_cache_clean_inval_all(curr);
diff --git a/src/target/armv7a_cache_l2x.c b/src/target/armv7a_cache_l2x.c
index 8ecdb00..6b42fae 100644
--- a/src/target/armv7a_cache_l2x.c
+++ b/src/target/armv7a_cache_l2x.c
@@ -210,7 +210,7 @@ static int armv7a_l2x_cache_init(struct target *target, uint32_t base, uint32_t
/* initialize all targets in this cluster (smp target)
* l2 cache must be configured after smp declaration */
- while (head != (struct target_list *)NULL) {
+ while (head) {
curr = head->target;
if (curr != target) {
armv7a = target_to_armv7a(curr);
diff --git a/src/target/armv8_cache.c b/src/target/armv8_cache.c
index b668b84..f05ac07 100644
--- a/src/target/armv8_cache.c
+++ b/src/target/armv8_cache.c
@@ -252,7 +252,7 @@ static int armv8_flush_all_data(struct target *target)
struct target_list *head;
struct target *curr;
head = target->head;
- while (head != (struct target_list *)NULL) {
+ while (head) {
curr = head->target;
if (curr->state == TARGET_HALTED) {
LOG_INFO("Wait flushing data l1 on core %" PRId32, curr->coreid);
diff --git a/src/target/breakpoints.c b/src/target/breakpoints.c
index dfec750..dd901ef 100644
--- a/src/target/breakpoints.c
+++ b/src/target/breakpoints.c
@@ -224,7 +224,7 @@ int breakpoint_add(struct target *target,
if (type == BKPT_SOFT)
return breakpoint_add_internal(head->target, address, length, type);
- while (head != (struct target_list *)NULL) {
+ while (head) {
curr = head->target;
retval = breakpoint_add_internal(curr, address, length, type);
if (retval != ERROR_OK)
@@ -247,7 +247,7 @@ int context_breakpoint_add(struct target *target,
struct target_list *head;
struct target *curr;
head = target->head;
- while (head != (struct target_list *)NULL) {
+ while (head) {
curr = head->target;
retval = context_breakpoint_add_internal(curr, asid, length, type);
if (retval != ERROR_OK)
@@ -271,7 +271,7 @@ int hybrid_breakpoint_add(struct target *target,
struct target_list *head;
struct target *curr;
head = target->head;
- while (head != (struct target_list *)NULL) {
+ while (head) {
curr = head->target;
retval = hybrid_breakpoint_add_internal(curr, address, asid, length, type);
if (retval != ERROR_OK)
@@ -347,7 +347,7 @@ void breakpoint_remove(struct target *target, target_addr_t address)
struct target_list *head;
struct target *curr;
head = target->head;
- while (head != (struct target_list *)NULL) {
+ while (head) {
curr = head->target;
num_breakpoints += breakpoint_remove_internal(curr, address);
head = head->next;
@@ -365,7 +365,7 @@ void breakpoint_remove_all(struct target *target)
struct target_list *head;
struct target *curr;
head = target->head;
- while (head != (struct target_list *)NULL) {
+ while (head) {
curr = head->target;
breakpoint_remove_all_internal(curr);
head = head->next;
@@ -389,7 +389,7 @@ void breakpoint_clear_target(struct target *target)
struct target_list *head;
struct target *curr;
head = target->head;
- while (head != (struct target_list *)NULL) {
+ while (head) {
curr = head->target;
breakpoint_clear_target_internal(curr);
head = head->next;
diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c
index b1f2206..241f2e6 100644
--- a/src/target/cortex_a.c
+++ b/src/target/cortex_a.c
@@ -641,7 +641,7 @@ static struct target *get_cortex_a(struct target *target, int32_t coreid)
struct target *curr;
head = target->head;
- while (head != (struct target_list *)NULL) {
+ while (head) {
curr = head->target;
if ((curr->coreid == coreid) && (curr->state == TARGET_HALTED))
return curr;
@@ -657,7 +657,7 @@ static int cortex_a_halt_smp(struct target *target)
struct target_list *head;
struct target *curr;
head = target->head;
- while (head != (struct target_list *)NULL) {
+ while (head) {
curr = head->target;
if ((curr != target) && (curr->state != TARGET_HALTED)
&& target_was_examined(curr))
@@ -953,7 +953,7 @@ static int cortex_a_restore_smp(struct target *target, int handle_breakpoints)
struct target *curr;
target_addr_t address;
head = target->head;
- while (head != (struct target_list *)NULL) {
+ while (head) {
curr = head->target;
if ((curr != target) && (curr->state != TARGET_RUNNING)
&& target_was_examined(curr)) {
diff --git a/src/target/mips_m4k.c b/src/target/mips_m4k.c
index cd06893..ca44169 100644
--- a/src/target/mips_m4k.c
+++ b/src/target/mips_m4k.c
@@ -131,7 +131,7 @@ static struct target *get_mips_m4k(struct target *target, int32_t coreid)
struct target *curr;
head = target->head;
- while (head != (struct target_list *)NULL) {
+ while (head) {
curr = head->target;
if ((curr->coreid == coreid) && (curr->state == TARGET_HALTED))
return curr;
@@ -146,7 +146,7 @@ static int mips_m4k_halt_smp(struct target *target)
struct target_list *head;
struct target *curr;
head = target->head;
- while (head != (struct target_list *)NULL) {
+ while (head) {
int ret = ERROR_OK;
curr = head->target;
if ((curr != target) && (curr->state != TARGET_HALTED))
@@ -417,7 +417,7 @@ static int mips_m4k_restore_smp(struct target *target, uint32_t address, int han
struct target *curr;
head = target->head;
- while (head != (struct target_list *)NULL) {
+ while (head) {
int ret = ERROR_OK;
curr = head->target;
if ((curr != target) && (curr->state != TARGET_RUNNING)) {
diff --git a/src/target/smp.c b/src/target/smp.c
index 94c4da5..518f6e4 100644
--- a/src/target/smp.c
+++ b/src/target/smp.c
@@ -137,7 +137,7 @@ COMMAND_HANDLER(handle_smp_gdb_command)
int retval = ERROR_OK;
struct target_list *head;
head = target->head;
- if (head != (struct target_list *)NULL) {
+ if (head) {
if (CMD_ARGC == 1) {
int coreid = 0;
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], coreid);
diff --git a/src/target/target.c b/src/target/target.c
index 7bace83..49f205a 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -5999,7 +5999,7 @@ static int jim_target_smp(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
new = malloc(sizeof(struct target_list));
new->target = target;
new->next = (struct target_list *)NULL;
- if (head == (struct target_list *)NULL) {
+ if (!head) {
head = new;
curr = head;
} else {
@@ -6011,7 +6011,7 @@ static int jim_target_smp(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
/* now parse the list of cpu and put the target in smp mode*/
curr = head;
- while (curr != (struct target_list *)NULL) {
+ while (curr) {
target = curr->target;
target->smp = 1;
target->head = head;