From 5cb8860b45b445ebb3e5961b0e06c720ae0d42f2 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 30 Dec 2019 18:25:04 +0100 Subject: [PATCH] unix: suppress -Waddress-of-packed-member warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: https://github.com/libuv/libuv/issues/2418 PR-URL: https://github.com/libuv/libuv/pull/2584 Refs: https://github.com/libuv/libuv/pull/2580 Reviewed-By: Colin Ihrig Reviewed-By: Santiago Gimeno Reviewed-By: Saúl Ibarra Corretgé --- src/unix/linux-core.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/unix/linux-core.c b/src/unix/linux-core.c index a155a374e..740e422d4 100644 --- a/src/unix/linux-core.c +++ b/src/unix/linux-core.c @@ -359,9 +359,19 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { have_signals = 0; nevents = 0; - assert(loop->watchers != NULL); - loop->watchers[loop->nwatchers] = (void*) events; - loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds; + { + /* Squelch a -Waddress-of-packed-member warning with gcc >= 9. */ + union { + struct epoll_event* events; + uv__io_t* watchers; + } x; + + x.events = events; + assert(loop->watchers != NULL); + loop->watchers[loop->nwatchers] = x.watchers; + loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds; + } + for (i = 0; i < nfds; i++) { pe = events + i; fd = pe->data.fd;