From 5706bf3efa8d8262982bbed15fb041e536f56cf2 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sat, 7 Oct 2023 14:26:23 +0200 Subject: lib: Wrap pthread_cond_timedwait for NULL abstime We often have the pattern where we NULL-check abstime for pthread_cond_timedwait to call pthread_cond_wait if it is. Added a __timedwait function to wrap this. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/lib/frct.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/lib/frct.c') diff --git a/src/lib/frct.c b/src/lib/frct.c index a3408481..7218837a 100644 --- a/src/lib/frct.c +++ b/src/lib/frct.c @@ -571,12 +571,7 @@ static int __frcti_window_wait(struct frcti * frcti, pthread_cleanup_push(__cleanup_mutex_unlock, &frcti->mtx); - if (abstime != NULL) - ret = -pthread_cond_timedwait(&frcti->cond, - &frcti->mtx, - abstime); - else - ret = -pthread_cond_wait(&frcti->cond, &frcti->mtx); + ret = -__timedwait(&frcti->cond, &frcti->mtx, abstime); pthread_cleanup_pop(false); -- cgit v1.2.3