From 3a90fd575146a61d199014fda6b6420161575f41 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 1 Feb 2018 19:11:23 -0800 Subject: Avoid an unnecessary temp variable --- common/threads.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'common/threads.c') diff --git a/common/threads.c b/common/threads.c index c1b062cd..999bb768 100644 --- a/common/threads.c +++ b/common/threads.c @@ -751,8 +751,8 @@ void alcnd_destroy(alcnd_t *cond) int alsem_init(alsem_t *sem, unsigned int initial) { - int ret = sem_init(sem, 0, initial); - if(ret == 0) return althrd_success; + if(sem_init(sem, 0, initial) == 0) + return althrd_success; return althrd_error; } @@ -763,23 +763,21 @@ void alsem_destroy(alsem_t *sem) int alsem_post(alsem_t *sem) { - int ret = sem_post(sem); - if(ret == 0) return althrd_success; + if(sem_post(sem) == 0) + return althrd_success; return althrd_error; } int alsem_wait(alsem_t *sem) { - int ret = sem_wait(sem); - if(ret == 0) return althrd_success; + if(sem_wait(sem) == 0) return althrd_success; if(errno == EINTR) return -2; return althrd_error; } int alsem_timedwait(alsem_t *sem, const struct timespec *time_point) { - int ret = sem_timedwait(sem, time_point); - if(ret == 0) return althrd_success; + if(sem_timedwait(sem, time_point) == 0) return althrd_success; if(errno == ETIMEDOUT) return althrd_timedout; if(errno == EINTR) return -2; return althrd_error; -- cgit v1.2.3