Revert "Remove duplicate of a counter in hwthread_update_threads" 07/7307/5
authorTomas Vanek <vanekt@fbl.cz>
Sun, 30 Oct 2022 08:22:37 +0000 (08:22 +0000)
committerAntonio Borneo <borneo.antonio@gmail.com>
Fri, 11 Nov 2022 20:22:53 +0000 (20:22 +0000)
Commit 0cedf10f8fd6 ("Remove duplicate of a counter in
hwthread_update_threads") introduced a code bug.

In the second foreach_smp_target() loop, variable "threads_found"
gets passed to routine hwthread_fill_thread(). By removing the
counting of threads_found from the second loop, the
incorrect thread counter value gets passed to hwthread_fill_thread().

Change-Id: Ie89e53ccd28bb72b6838ef2f12106a1fe8d00994
Suggested-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7307
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
src/rtos/hwthread.c

index bdd5835c27dfe0f6e35353333bf16e4feb8e04f7..e5eaf425f63da8d31863629ae57f165ed38d842f 100644 (file)
@@ -78,6 +78,7 @@ 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;
@@ -99,13 +100,13 @@ static int hwthread_update_threads(struct rtos *rtos)
                        if (!target_was_examined(curr))
                                continue;
 
-                       ++threads_found;
+                       ++thread_list_size;
                }
        } else
-               threads_found = 1;
+               thread_list_size = 1;
 
        /* create space for new thread details */
-       rtos->thread_details = malloc(sizeof(struct thread_detail) * threads_found);
+       rtos->thread_details = malloc(sizeof(struct thread_detail) * thread_list_size);
 
        if (target->smp) {
                /* loop over all threads */
@@ -170,10 +171,13 @@ 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)