From db1fc77e7541b2fda2307453903bf4be2722ef08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20J=2E=20Saraiva?= Date: Tue, 26 Mar 2024 16:02:07 +0000 Subject: [PATCH] Ensure the timeout time is reached in cpu_idle_loop. This is an attempt to silence a coverity issue. --- stable/cpu.c | 3 ++- unstable/cpu.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/stable/cpu.c b/stable/cpu.c index 6a6c6d3bc..49977b3ea 100644 --- a/stable/cpu.c +++ b/stable/cpu.c @@ -384,7 +384,8 @@ void cpu_idle_loop(cpu_gen_t *cpu) pthread_mutex_lock(&cpu->idle_mutex); t_spc.tv_sec = expire / 1000000; t_spc.tv_nsec = (expire % 1000000) * 1000; - pthread_cond_timedwait(&cpu->idle_cond,&cpu->idle_mutex,&t_spc); + while(pthread_cond_timedwait(&cpu->idle_cond,&cpu->idle_mutex,&t_spc) != ETIMEDOUT) { + } pthread_mutex_unlock(&cpu->idle_mutex); } diff --git a/unstable/cpu.c b/unstable/cpu.c index 1e156022f..e03fb36bc 100644 --- a/unstable/cpu.c +++ b/unstable/cpu.c @@ -334,7 +334,8 @@ void cpu_idle_loop(cpu_gen_t *cpu) pthread_mutex_lock(&cpu->idle_mutex); t_spc.tv_sec = expire / 1000000; t_spc.tv_nsec = (expire % 1000000) * 1000; - pthread_cond_timedwait(&cpu->idle_cond,&cpu->idle_mutex,&t_spc); + while(pthread_cond_timedwait(&cpu->idle_cond,&cpu->idle_mutex,&t_spc) != ETIMEDOUT) { + } pthread_mutex_unlock(&cpu->idle_mutex); }