pipewire: thread-loop: print thread id as pointer

On musl, `pthread_t` is a pointer type, so printing it
as a long generates warnings. So cast it to `void *`
and print it with "%p" since it is actually a pointer
even on glibc (nptl) (at least at the time of writing...).
This commit is contained in:
Barnabás Pőcze 2023-06-10 02:23:09 +02:00
parent dfb3cb20af
commit b52be160ab

View file

@ -50,7 +50,7 @@ static int do_lock(struct pw_thread_loop *this)
{ {
int res; int res;
if ((res = pthread_mutex_lock(&this->lock)) != 0) if ((res = pthread_mutex_lock(&this->lock)) != 0)
pw_log_error("%p: thread:%lu: %s", this, pthread_self(), strerror(res)); pw_log_error("%p: thread:%p: %s", this, (void *) pthread_self(), strerror(res));
else else
this->recurse++; this->recurse++;
return -res; return -res;
@ -62,7 +62,7 @@ static int do_unlock(struct pw_thread_loop *this)
spa_return_val_if_fail(this->recurse > 0, -EIO); spa_return_val_if_fail(this->recurse > 0, -EIO);
this->recurse--; this->recurse--;
if ((res = pthread_mutex_unlock(&this->lock)) != 0) { if ((res = pthread_mutex_unlock(&this->lock)) != 0) {
pw_log_error("%p: thread:%lu: %s", this, pthread_self(), strerror(res)); pw_log_error("%p: thread:%p: %s", this, (void *) pthread_self(), strerror(res));
this->recurse++; this->recurse++;
} }
return -res; return -res;
@ -97,13 +97,13 @@ static int impl_check(void *data, struct pw_loop *loop)
/* if lock taken by something else, error */ /* if lock taken by something else, error */
if ((res = pthread_mutex_trylock(&this->lock)) != 0) { if ((res = pthread_mutex_trylock(&this->lock)) != 0) {
pw_log_debug("%p: thread:%lu: %s", this, pthread_self(), strerror(res)); pw_log_debug("%p: thread:%p: %s", this, (void *) pthread_self(), strerror(res));
return -res; return -res;
} }
/* we could take the lock, check if we actually locked it somewhere */ /* we could take the lock, check if we actually locked it somewhere */
res = this->recurse > 0 ? 1 : -EPERM; res = this->recurse > 0 ? 1 : -EPERM;
if (res < 0) if (res < 0)
pw_log_debug("%p: thread:%lu: recurse:%d", this, pthread_self(), this->recurse); pw_log_debug("%p: thread:%p: recurse:%d", this, (void *) pthread_self(), this->recurse);
pthread_mutex_unlock(&this->lock); pthread_mutex_unlock(&this->lock);
return res; return res;
} }
@ -398,7 +398,7 @@ void pw_thread_loop_signal(struct pw_thread_loop *loop, bool wait_for_accept)
while (loop->n_waiting_for_accept > 0) { while (loop->n_waiting_for_accept > 0) {
int res; int res;
if ((res = pthread_cond_wait(&loop->accept_cond, &loop->lock)) != 0) if ((res = pthread_cond_wait(&loop->accept_cond, &loop->lock)) != 0)
pw_log_error("%p: thread:%lu: %s", loop, pthread_self(), strerror(res)); pw_log_error("%p: thread:%p: %s", loop, (void *) pthread_self(), strerror(res));
} }
} }
} }
@ -418,7 +418,7 @@ void pw_thread_loop_wait(struct pw_thread_loop *loop)
loop->n_waiting++; loop->n_waiting++;
loop->recurse--; loop->recurse--;
if ((res = pthread_cond_wait(&loop->cond, &loop->lock)) != 0) if ((res = pthread_cond_wait(&loop->cond, &loop->lock)) != 0)
pw_log_error("%p: thread:%lu: %s", loop, pthread_self(), strerror(res)); pw_log_error("%p: thread:%p: %s", loop, (void *) pthread_self(), strerror(res));
loop->recurse++; loop->recurse++;
loop->n_waiting--; loop->n_waiting--;
pw_log_trace("%p, waiting done %d", loop, loop->n_waiting); pw_log_trace("%p, waiting done %d", loop, loop->n_waiting);