target/breakpoints: Remove dead code and cleanup 21/6321/2
authorMarc Schink <dev@zapb.de>
Tue, 15 Jun 2021 14:49:37 +0000 (16:49 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 26 Jun 2021 13:42:01 +0000 (14:42 +0100)
Change-Id: I8027178b6e771753775514a8641a050c6e63a1d5
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6321
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
src/target/breakpoints.c

index c060c7cde7d577ef94f74c8f0a30d9c72db9a3af..dc8f3c5730a38e37fa255a9ba003ba2100ef299b 100644 (file)
@@ -50,11 +50,8 @@ static int breakpoint_add_internal(struct target *target,
        struct breakpoint **breakpoint_p = &target->breakpoints;
        const char *reason;
        int retval;
-       int n;
 
-       n = 0;
        while (breakpoint) {
-               n++;
                if (breakpoint->address == address) {
                        /* FIXME don't assume "same address" means "same
                         * breakpoint" ... check all the parameters before
@@ -114,11 +111,8 @@ static int context_breakpoint_add_internal(struct target *target,
        struct breakpoint *breakpoint = target->breakpoints;
        struct breakpoint **breakpoint_p = &target->breakpoints;
        int retval;
-       int n;
 
-       n = 0;
        while (breakpoint) {
-               n++;
                if (breakpoint->asid == asid) {
                        /* FIXME don't assume "same address" means "same
                         * breakpoint" ... check all the parameters before
@@ -167,10 +161,8 @@ static int hybrid_breakpoint_add_internal(struct target *target,
        struct breakpoint *breakpoint = target->breakpoints;
        struct breakpoint **breakpoint_p = &target->breakpoints;
        int retval;
-       int n;
-       n = 0;
+
        while (breakpoint) {
-               n++;
                if ((breakpoint->asid == asid) && (breakpoint->address == address)) {
                        /* FIXME don't assume "same address" means "same
                         * breakpoint" ... check all the parameters before
@@ -238,8 +230,9 @@ int breakpoint_add(struct target *target,
                        head = head->next;
                }
                return retval;
-       } else
+       } else {
                return breakpoint_add_internal(target, address, length, type);
+       }
 }
 
 int context_breakpoint_add(struct target *target,
@@ -260,8 +253,9 @@ int context_breakpoint_add(struct target *target,
                        head = head->next;
                }
                return retval;
-       } else
+       } else {
                return context_breakpoint_add_internal(target, asid, length, type);
+       }
 }
 
 int hybrid_breakpoint_add(struct target *target,
@@ -301,7 +295,7 @@ static void breakpoint_free(struct target *target, struct breakpoint *breakpoint
                breakpoint = breakpoint->next;
        }
 
-       if (breakpoint == NULL)
+       if (!breakpoint)
                return;
 
        retval = target_remove_breakpoint(target, breakpoint);
@@ -346,20 +340,21 @@ static void breakpoint_remove_all_internal(struct target *target)
 
 void breakpoint_remove(struct target *target, target_addr_t address)
 {
-       int found = 0;
        if (target->smp) {
+               unsigned int num_breakpoints = 0;
                struct target_list *head;
                struct target *curr;
                head = target->head;
                while (head != (struct target_list *)NULL) {
                        curr = head->target;
-                       found += breakpoint_remove_internal(curr, address);
+                       num_breakpoints += breakpoint_remove_internal(curr, address);
                        head = head->next;
                }
-               if (found == 0)
+               if (!num_breakpoints)
                        LOG_ERROR("no breakpoint at address " TARGET_ADDR_FMT " found", address);
-       } else
+       } else {
                breakpoint_remove_internal(target, address);
+       }
 }
 
 void breakpoint_remove_all(struct target *target)
@@ -397,9 +392,9 @@ void breakpoint_clear_target(struct target *target)
                        breakpoint_clear_target_internal(curr);
                        head = head->next;
                }
-       } else
+       } else {
                breakpoint_clear_target_internal(target);
-
+       }
 }
 
 struct breakpoint *breakpoint_find(struct target *target, target_addr_t address)
@@ -494,7 +489,7 @@ static void watchpoint_free(struct target *target, struct watchpoint *watchpoint
                watchpoint = watchpoint->next;
        }
 
-       if (watchpoint == NULL)
+       if (!watchpoint)
                return;
        retval = target_remove_watchpoint(target, watchpoint);
        LOG_DEBUG("free WPID: %d --> %d", watchpoint->unique_id, retval);

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)