Suppress -Wdangling-pointer in event_signal_closure()

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
This commit is contained in:
Azat Khuzhin 2022-11-12 18:06:09 +01:00
parent e1d7d3e40a
commit 2dfad6c339

14
event.c
View File

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