cppcheck stuff

This commit is contained in:
iceman1001 2022-01-09 13:38:16 +01:00
parent 0967ea1989
commit 7c8be44dd6

View file

@ -248,7 +248,9 @@ int thread_start_scheduler(thread_ctx_t *ctx, thread_args_t *t_arg, wu_queue_ctx
pthread_mutex_lock(&ctx->thread_mutexs[z]);
t_arg[z].status = TH_END;
t_arg[z].quit = true;
if (cur_status == TH_WAIT) pthread_cond_signal(&ctx->thread_conds[z]);
if (cur_status == TH_WAIT) {
pthread_cond_signal(&ctx->thread_conds[z]);
}
pthread_mutex_unlock(&ctx->thread_mutexs[z]);
} else {
if (ctx->thread_count == 1) {
@ -306,7 +308,9 @@ int thread_start_scheduler(thread_ctx_t *ctx, thread_args_t *t_arg, wu_queue_ctx
printf("[master] thread [%zu], got the signal with new state: %s.\n", z, thread_status_strdesc(t_arg[z].status));
fflush(stdout);
#endif
if (t_arg[z].status == TH_FOUND_KEY) found = true;
if (t_arg[z].status == TH_FOUND_KEY) {
found = true;
}
pthread_mutex_unlock(&ctx->thread_mutex_usleep);
#if TDEBUG >= 1
@ -316,17 +320,18 @@ int thread_start_scheduler(thread_ctx_t *ctx, thread_args_t *t_arg, wu_queue_ctx
continue;
}
if (found) {
// since found is handled before this part (line 237), removing the if-statement
// doesn't change anything according to cppcheck.
#if TDEBUG >= 1
printf("[master] thread [%zu], the key is found. set TH_END from TH_PROCESSING\n", z);
fflush(stdout);
printf("[master] thread [%zu], the key is found. set TH_END from TH_PROCESSING\n", z);
fflush(stdout);
#endif
pthread_mutex_lock(&ctx->thread_mutexs[z]);
t_arg[z].status = TH_END;
t_arg[z].quit = true;
pthread_mutex_unlock(&ctx->thread_mutexs[z]);
continue;
}
pthread_mutex_lock(&ctx->thread_mutexs[z]);
t_arg[z].status = TH_END;
t_arg[z].quit = true;
pthread_mutex_unlock(&ctx->thread_mutexs[z]);
continue;
}
if (cur_status == TH_ERROR) {
// something went wrong