diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2014-07-19 17:44:49 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2014-07-19 17:44:49 +0200 |
commit | 027333e56aeea20c486702ecfb9571ca45fd14f6 (patch) | |
tree | f05033ff39575abf4010392920caa36b58b3b734 /src/common.c | |
parent | 43d34d2473917521376f7d56126779f941205105 (diff) | |
download | xK-027333e56aeea20c486702ecfb9571ca45fd14f6.tar.gz xK-027333e56aeea20c486702ecfb9571ca45fd14f6.tar.xz xK-027333e56aeea20c486702ecfb9571ca45fd14f6.zip |
Fix some compiler warnings
`-Weverything' seems to have found a few problems.
Also enabled clang sanitizers by default.
Diffstat (limited to 'src/common.c')
-rw-r--r-- | src/common.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/common.c b/src/common.c index 96548d9..b3d5e1b 100644 --- a/src/common.c +++ b/src/common.c @@ -982,7 +982,11 @@ poller_timers_get_poll_timeout (struct poller_timers *self) return -1; int64_t timeout = self->info->when - poller_timers_get_current_time (); - return timeout >= 0 ? timeout : 0; + if (timeout <= 0) + return 0; + if (timeout > INT_MAX) + return INT_MAX; + return timeout; } #ifdef __linux__ @@ -994,7 +998,7 @@ poller_timers_get_poll_timeout (struct poller_timers *self) struct poller_info { int fd; ///< Our file descriptor - uint32_t events; ///< The events we registered + short events; ///< The poll() events we registered for poller_dispatcher_func dispatcher; ///< Event dispatcher void *user_data; ///< User data }; @@ -1074,10 +1078,10 @@ poller_ensure_space (struct poller *self) (self->info, sizeof *self->info, self->alloc); } -static int -poller_epoll_to_poll_events (int events) +static short +poller_epoll_to_poll_events (uint32_t events) { - int result = 0; + short result = 0; if (events & EPOLLIN) result |= POLLIN; if (events & EPOLLOUT) result |= POLLOUT; if (events & EPOLLERR) result |= POLLERR; @@ -1087,7 +1091,7 @@ poller_epoll_to_poll_events (int events) } static uint32_t -poller_poll_to_epoll_events (uint32_t events) +poller_poll_to_epoll_events (short events) { uint32_t result = 0; if (events & POLLIN) result |= EPOLLIN; @@ -1099,7 +1103,7 @@ poller_poll_to_epoll_events (uint32_t events) } static void -poller_set (struct poller *self, int fd, short int events, +poller_set (struct poller *self, int fd, short events, poller_dispatcher_func dispatcher, void *data) { ssize_t index = poller_find_by_fd (self, fd); @@ -1185,7 +1189,7 @@ poller_run (struct poller *self) struct pollfd pfd; pfd.fd = info->fd; pfd.revents = poller_epoll_to_poll_events (revents->events); - pfd.events = poller_epoll_to_poll_events (info->events); + pfd.events = info->events; self->dispatch_next++; info->dispatcher (&pfd, info->user_data); @@ -1255,7 +1259,7 @@ poller_ensure_space (struct poller *self) } static void -poller_set (struct poller *self, int fd, short int events, +poller_set (struct poller *self, int fd, short events, poller_dispatcher_func dispatcher, void *data) { ssize_t index = poller_find_by_fd (self, fd); |