From a5ffb50dd78ee430641fa8b68b9a3b6d488fb562 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 2 Jul 2019 11:36:06 +0200 Subject: [PATCH] unix: squelch -Wcast-function-type warning PR-URL: https://github.com/libuv/libuv/pull/2346 Reviewed-By: Santiago Gimeno --- src/unix/thread.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/unix/thread.c b/src/unix/thread.c index cd0b7aa6..35b47214 100644 --- a/src/unix/thread.c +++ b/src/unix/thread.c @@ -222,6 +222,12 @@ int uv_thread_create_ex(uv_thread_t* tid, size_t pagesize; size_t stack_size; + /* Used to squelch a -Wcast-function-type warning. */ + union { + void (*in)(void*); + void* (*out)(void*); + } f; + stack_size = params->flags & UV_THREAD_HAS_STACK_SIZE ? params->stack_size : 0; @@ -248,7 +254,8 @@ int uv_thread_create_ex(uv_thread_t* tid, abort(); } - err = pthread_create(tid, attr, (void*(*)(void*)) entry, arg); + f.in = entry; + err = pthread_create(tid, attr, f.out, arg); if (attr != NULL) pthread_attr_destroy(attr);