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);
This commit is contained in:
Barnabás Pőcze 2022-08-11 16:45:25 +02:00
parent 4a0395d23e
commit 3f3b70ad83
1 changed files with 1 additions and 1 deletions

View File

@ -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)