From 3f3b70ad83c1c6af8150752ac66bdbe2def7c329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Thu, 11 Aug 2022 16:45:25 +0200 Subject: [PATCH] pipewire-jack: return a zero initialized `pthread_t` in case of error When the `client` argument is NULL, return a zero initialized `pthread_t` object from `jack_client_thread_id()`. Returning `-EINVAL` can be problematic because even though `pthread_t` is a typedef for `unsigned long` in glibc, it is still a pointer, not a numeric identifier. And in musl, it is a typedef to a pointer, which results in a warning: In file included from ../spa/include/spa/support/cpu.h:34, from ../pipewire-jack/src/pipewire-jack.c:40: ../pipewire-jack/src/pipewire-jack.c: In function 'jack_client_thread_id': ../spa/include/spa/utils/defs.h:274:11: warning: returning 'int' from a function with return type 'jack_native_thread_t' {aka 'struct __pthread *'} makes pointer from integer without a cast [-Wint-conversion] 274 | return (val); \ | ^ ../pipewire-jack/src/pipewire-jack.c:3775:2: note: in expansion of macro 'spa_return_val_if_fail' 3775 | spa_return_val_if_fail(c != NULL, -EINVAL); --- pipewire-jack/src/pipewire-jack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipewire-jack/src/pipewire-jack.c b/pipewire-jack/src/pipewire-jack.c index 3b0c866cb..6a7726ca1 100644 --- a/pipewire-jack/src/pipewire-jack.c +++ b/pipewire-jack/src/pipewire-jack.c @@ -3772,7 +3772,7 @@ jack_native_thread_t jack_client_thread_id (jack_client_t *client) struct client *c = (struct client *) client; void *thr; - spa_return_val_if_fail(c != NULL, -EINVAL); + spa_return_val_if_fail(c != NULL, (pthread_t){0}); thr = pw_data_loop_get_thread(c->loop); if (thr == NULL)