Skip to content

Commit

Permalink
Fix error checks on pthread calls.
Browse files Browse the repository at this point in the history
Found using valgrind.
  • Loading branch information
pbeyssac committed Sep 1, 2024
1 parent 1b5ac37 commit 4f62e8f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions caster/jobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct joblist *joblist_new(struct caster_state *caster) {
STAILQ_INIT(&this->append_jobq);
P_MUTEX_INIT(&this->mutex, NULL);
P_MUTEX_INIT(&this->append_mutex, NULL);
if (pthread_cond_init(&this->condjob, NULL) < 0)
if (pthread_cond_init(&this->condjob, NULL) != 0)
caster_log_error(this->caster, "pthread_cond_init");
}
return this;
Expand Down Expand Up @@ -74,7 +74,7 @@ void joblist_free(struct joblist *this) {
P_MUTEX_UNLOCK(&this->mutex);
P_MUTEX_DESTROY(&this->mutex);
P_MUTEX_DESTROY(&this->append_mutex);
if (pthread_cond_destroy(&this->condjob) < 0)
if (pthread_cond_destroy(&this->condjob) != 0)
caster_log_error(this->caster, "pthread_cond_signal");
free(this);
}
Expand Down Expand Up @@ -149,7 +149,7 @@ void joblist_run(struct joblist *this) {
/*
* All queues empty => wait.
*/
if (pthread_cond_wait(&this->condjob, &this->mutex) < 0)
if (pthread_cond_wait(&this->condjob, &this->mutex) != 0)
caster_log_error(this->caster, "pthread_cond_wait");
continue;
}
Expand Down Expand Up @@ -339,7 +339,7 @@ static void _joblist_append_generic(struct joblist *this, struct ntrip_state *st
/*
* Signal waiting workers there is a new job.
*/
if (pthread_cond_signal(&this->condjob) < 0)
if (pthread_cond_signal(&this->condjob) != 0)
caster_log_error(this->caster, "pthread_cond_signal");
P_MUTEX_UNLOCK(&this->append_mutex);
}
Expand Down

0 comments on commit 4f62e8f

Please sign in to comment.