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/shm_rdrbuff.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/lib/shm_rdrbuff.c') diff --git a/src/lib/shm_rdrbuff.c b/src/lib/shm_rdrbuff.c index 56ae484e..a8c346ae 100644 --- a/src/lib/shm_rdrbuff.c +++ b/src/lib/shm_rdrbuff.c @@ -402,13 +402,7 @@ ssize_t shm_rdrbuff_alloc_b(struct shm_rdrbuff * rdrb, #else while (!shm_rdrb_free(rdrb, 1) && ret != ETIMEDOUT) { #endif - if (abstime != NULL) - ret = pthread_cond_timedwait(rdrb->healthy, - rdrb->lock, - abstime); - else - ret = pthread_cond_wait(rdrb->healthy, rdrb->lock); - + ret = __timedwait(rdrb->healthy, rdrb->lock, abstime); #ifdef SHM_RDRB_MULTI_BLOCK if (blocks + *rdrb->head > (SHM_BUFFER_SIZE)) padblocks = (SHM_BUFFER_SIZE) - *rdrb->head; -- cgit v1.2.3