Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pthread returns #444

Merged
merged 1 commit into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions include/tlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand Down Expand Up @@ -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 *));
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions lib/loop_timerlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/rpl_sem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down