Remove duplicate of a counter in hwthread_update_threads

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>
This commit is contained in:
Evgeniy Naydanov 2022-09-14 17:56:20 +03:00 committed by Antonio Borneo
parent 759d581fde
commit 0cedf10f8f
1 changed files with 3 additions and 7 deletions

View 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) static int hwthread_update_threads(struct rtos *rtos)
{ {
int threads_found = 0; int threads_found = 0;
int thread_list_size = 0;
struct target_list *head; struct target_list *head;
struct target *target; struct target *target;
int64_t current_thread = 0; int64_t current_thread = 0;
@ -100,13 +99,13 @@ static int hwthread_update_threads(struct rtos *rtos)
if (!target_was_examined(curr)) if (!target_was_examined(curr))
continue; continue;
++thread_list_size; ++threads_found;
} }
} else } else
thread_list_size = 1; threads_found = 1;
/* create space for new thread details */ /* 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) { if (target->smp) {
/* loop over all threads */ /* loop over all threads */
@ -171,13 +170,10 @@ static int hwthread_update_threads(struct rtos *rtos)
default: default:
break; break;
} }
threads_found++;
} }
} else { } else {
hwthread_fill_thread(rtos, target, threads_found); hwthread_fill_thread(rtos, target, threads_found);
current_thread = threadid_from_target(target); current_thread = threadid_from_target(target);
threads_found++;
} }
rtos->thread_count = threads_found; rtos->thread_count = threads_found;