openocd: remove last NULL comparisons
The NULL pointers preceded by cast where not detected by the scripting tools looking for NULL pointer comparison. Remove them and, while there, further simplify the code and apply the other coding style rules. Change-Id: Ia7406122e07ef56ef311579ab0ee7ddb22c8e4b5 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6539 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user