diff --git a/include/tlist.h b/include/tlist.h index 6735c9816..fe3d9a66c 100644 --- a/include/tlist.h +++ b/include/tlist.h @@ -284,8 +284,8 @@ static inline int32_t timerlist_add(struct timerlist *timerlist, struct timerlist_timer **new_heap_entries; int32_t res = 0; - if (pthread_mutex_lock(&timerlist->list_mutex)) { - return -errno; + if ( (res=pthread_mutex_lock(&timerlist->list_mutex))) { + return -res; } /* @@ -351,9 +351,10 @@ static inline int32_t timerlist_del(struct timerlist *timerlist, timer_handle _timer_handle) { struct timerlist_timer *timer = (struct timerlist_timer *)_timer_handle; + int res; - if (pthread_mutex_lock(&timerlist->list_mutex)) { - return -errno; + if ( (res=pthread_mutex_lock(&timerlist->list_mutex))) { + return -res; } memset(timer->handle_addr, 0, sizeof(struct timerlist_timer *)); @@ -453,12 +454,13 @@ static inline int32_t timerlist_expire(struct timerlist *timerlist) uint64_t current_time_from_epoch; uint64_t current_monotonic_time; uint64_t current_time; + int res; current_monotonic_time = qb_util_nano_current_get(); current_time_from_epoch = qb_util_nano_from_epoch_get(); - if (pthread_mutex_lock(&timerlist->list_mutex)) { - return -errno; + if ( (res=pthread_mutex_lock(&timerlist->list_mutex))) { + return -res; } while (timerlist->size > 0) { diff --git a/lib/loop_timerlist.c b/lib/loop_timerlist.c index 59cb1a138..9aef348ad 100644 --- a/lib/loop_timerlist.c +++ b/lib/loop_timerlist.c @@ -187,6 +187,7 @@ qb_loop_timer_add(struct qb_loop * lp, struct qb_loop_timer *t; struct qb_timer_source *my_src; int32_t i; + int res; struct qb_loop *l = lp; if (l == NULL) { @@ -198,8 +199,8 @@ qb_loop_timer_add(struct qb_loop * lp, } my_src = (struct qb_timer_source *)l->timer_source; - if (pthread_mutex_lock(&my_src->lock)) { - return -errno; + if ( (res=pthread_mutex_lock(&my_src->lock))) { + return -res; } i = _get_empty_array_position_(my_src); assert(qb_array_index(my_src->timers, i, (void **)&t) >= 0); diff --git a/lib/rpl_sem.c b/lib/rpl_sem.c index 7daeb4f2d..cb73f9d31 100644 --- a/lib/rpl_sem.c +++ b/lib/rpl_sem.c @@ -76,7 +76,7 @@ _rpl_sem_timedwait(rpl_sem_t * sem, const struct timespec *timeout) { int retval = pthread_mutex_lock(&sem->mutex); if (retval != 0) { - return -errno; + return -retval; } if (sem->destroy_request) { retval = -EINVAL;