Remove duplicate of a counter in hwthread_update_threads 23/7223/3
authorEvgeniy Naydanov <evgeniy.naydanov@syntacore.com>
Wed, 14 Sep 2022 14:56:20 +0000 (17:56 +0300)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 8 Oct 2022 07:52:12 +0000 (07:52 +0000)
There is no need to count number of examined threads twice.

Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
Change-Id: Id32ead853d1ddcd4e67062d6f795700feb20cb4b
Reviewed-on: https://review.openocd.org/c/openocd/+/7223
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
src/rtos/hwthread.c

index e5eaf425f63da8d31863629ae57f165ed38d842f..bdd5835c27dfe0f6e35353333bf16e4feb8e04f7 100644 (file)
@@ -78,7 +78,6 @@ static int hwthread_fill_thread(struct rtos *rtos, struct target *curr, int thre
 static int hwthread_update_threads(struct rtos *rtos)
 {
        int threads_found = 0;
-       int thread_list_size = 0;
        struct target_list *head;
        struct target *target;
        int64_t current_thread = 0;
@@ -100,13 +99,13 @@ static int hwthread_update_threads(struct rtos *rtos)
                        if (!target_was_examined(curr))
                                continue;
 
-                       ++thread_list_size;
+                       ++threads_found;
                }
        } else
-               thread_list_size = 1;
+               threads_found = 1;
 
        /* create space for new thread details */
-       rtos->thread_details = malloc(sizeof(struct thread_detail) * thread_list_size);
+       rtos->thread_details = malloc(sizeof(struct thread_detail) * threads_found);
 
        if (target->smp) {
                /* loop over all threads */
@@ -171,13 +170,10 @@ static int hwthread_update_threads(struct rtos *rtos)
                        default:
                                break;
                        }
-
-                       threads_found++;
                }
        } else {
                hwthread_fill_thread(rtos, target, threads_found);
                current_thread = threadid_from_target(target);
-               threads_found++;
        }
 
        rtos->thread_count = threads_found;

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)