Skip to content

Commit

Permalink
Suppress -Wdangling-pointer in event_signal_closure()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
azat committed Nov 12, 2022
1 parent e1d7d3e commit 2dfad6c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions event.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down

0 comments on commit 2dfad6c

Please sign in to comment.