From 2dfad6c339a68c42e98049e7e3d60db6d500a1ac Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sat, 12 Nov 2022 18:06:09 +0100 Subject: [PATCH] Suppress -Wdangling-pointer in event_signal_closure() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gcc 12 complains: [34/46] Building C object CMakeFiles/event_static.dir/event.c.o /src/le/libevent/event.c: In function ‘event_signal_closure’: /src/le/libevent/event.c:1384:32: warning: storing the address of local variable ‘ncalls’ in ‘*ev.ev_.ev_signal.ev_pncalls’ [-Wdangling-pointer=] 1384 | ev->ev_pncalls = &ncalls; | ~~~~~~~~~~~~~~~^~~~~~~~~ /src/le/libevent/event.c:1378:15: note: ‘ncalls’ declared here 1378 | short ncalls; | ^~~~~~ /src/le/libevent/event.c:1378:15: note: ‘ev’ declared here --- event.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/event.c b/event.c index 56be024f58..a7a6b3f472 100644 --- a/event.c +++ b/event.c @@ -1375,6 +1375,15 @@ event_haveevents(struct event_base *base) static inline void event_signal_closure(struct event_base *base, struct event *ev) { +#if defined(__clang__) +#elif defined(__GNUC__) +#pragma GCC diagnostic push +/* NOTE: it is better to avoid such code all together, by using separate + * variable to break the loop in the event structure, but now this code is safe + * */ +#pragma GCC diagnostic ignored "-Wdangling-pointer" +#endif + short ncalls; int should_break; @@ -1400,6 +1409,11 @@ event_signal_closure(struct event_base *base, struct event *ev) return; } } + +#if defined(__clang__) +#elif defined(__GNUC__) +#pragma GCC diagnostic pop +#endif } /* Common timeouts are special timeouts that are handled as queues rather than