commit 2d3f88f6b9c4db7a4f65f1dcebae296f662cbeb7 Author: cypherpunks cypherpunks@torproject.org Date: Thu Jul 2 09:43:20 2015 +0200
Remove casting of void pointers when handling signals. --- src/or/main.c | 12 +++++++----- src/or/main.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/or/main.c b/src/or/main.c index fe93cdc..5bff82b 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -2227,7 +2227,8 @@ run_main_loop_until_done(void) static void signal_callback(int fd, short events, void *arg) { - uintptr_t sig = (uintptr_t)arg; + const int *sigptr = arg; + const int sig = *sigptr; (void)fd; (void)events;
@@ -2237,7 +2238,7 @@ signal_callback(int fd, short events, void *arg)
/** Do the work of acting on a signal received in <b>sig</b> */ void -process_signal(uintptr_t sig) +process_signal(int sig) { switch (sig) { @@ -2482,9 +2483,10 @@ handle_signals(int is_parent) static struct event *signal_events[16]; /* bigger than it has to be. */ if (is_parent) { for (i = 0; signals[i] >= 0; ++i) { - signal_events[i] = tor_evsignal_new( - tor_libevent_get_base(), signals[i], signal_callback, - (void*)(uintptr_t)signals[i]); + signal_events[i] = tor_evsignal_new(tor_libevent_get_base(), signals[i], + signal_callback, + /* Cast away const */ + (int*)&signals[i]); if (event_add(signal_events[i], NULL)) log_warn(LD_BUG, "Error from libevent when adding event for signal %d", signals[i]); diff --git a/src/or/main.h b/src/or/main.h index 542eab6..be0bd64 100644 --- a/src/or/main.h +++ b/src/or/main.h @@ -60,7 +60,7 @@ MOCK_DECL(long,get_uptime,(void)); unsigned get_signewnym_epoch(void);
void handle_signals(int is_parent); -void process_signal(uintptr_t sig); +void process_signal(int sig);
int try_locking(const or_options_t *options, int err_if_locked); int have_lockfile(void);
tor-commits@lists.torproject.org