diff --git a/API.md b/API.md index 3d1bef2..6580f1e 100644 --- a/API.md +++ b/API.md @@ -314,16 +314,16 @@ static void joystick_cb(uev_t *w, void *arg, int events) int main(void) { - int fd; - uev_t watcher; uev_ctx_t ctx; + uev_t js; + int fd; fd = open("/dev/input/js0", O_RDONLY, O_NONBLOCK); if (fd < 0) errx(errno, "Cannot find a joystick attached."); uev_init(&ctx); - uev_io_init(&ctx, &watcher, joystick_cb, NULL, fd, UEV_READ); + uev_io_init(&ctx, &js, joystick_cb, NULL, fd, UEV_READ); puts("Starting, press Ctrl-C to exit."); diff --git a/examples/joystick.c b/examples/joystick.c index b3f45fe..97ed788 100644 --- a/examples/joystick.c +++ b/examples/joystick.c @@ -74,16 +74,16 @@ static void joystick_cb(uev_t *w, void *arg, int events) int main(void) { - int fd; - uev_t js1_watcher; uev_ctx_t ctx; + uev_t js1; + int fd; fd = open("/dev/input/js0", O_RDONLY, O_NONBLOCK); if (fd < 0) errx(errno, "Cannot find a joystick attached."); uev_init(&ctx); - uev_io_init(&ctx, &js1_watcher, joystick_cb, NULL, fd, UEV_READ); + uev_io_init(&ctx, &js1, joystick_cb, NULL, fd, UEV_READ); puts("Starting, press Ctrl-C to exit."); diff --git a/examples/redirect.c b/examples/redirect.c index bd2547b..5766fc1 100644 --- a/examples/redirect.c +++ b/examples/redirect.c @@ -47,9 +47,9 @@ void process_stdin(uev_t *w, void *arg, int events) int main(int argc, char **argv) { - int ret; - uev_t watcher; uev_ctx_t ctx; + uev_t watcher; + int ret; uev_init(&ctx); diff --git a/src/signal.c b/src/signal.c index a7efc4d..2422ae1 100644 --- a/src/signal.c +++ b/src/signal.c @@ -42,8 +42,8 @@ */ int uev_signal_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int signo) { - int fd; sigset_t mask; + int fd; if (!w || !ctx) { errno = EINVAL; diff --git a/src/uev.c b/src/uev.c index addcf6b..e450342 100644 --- a/src/uev.c +++ b/src/uev.c @@ -289,8 +289,8 @@ int uev_exit(uev_ctx_t *ctx) */ int uev_run(uev_ctx_t *ctx, int flags) { - int timeout = -1; uev_t *w; + int timeout = -1; if (!ctx || ctx->fd < 0) { errno = EINVAL; @@ -312,8 +312,8 @@ int uev_run(uev_ctx_t *ctx, int flags) } while (ctx->running && ctx->watchers) { - int i, nfds, rerun = 0; struct epoll_event ee[UEV_MAX_EVENTS]; + int i, nfds, rerun = 0; /* Handle special case: `application < file.txt` */ if (ctx->workaround) { @@ -349,9 +349,9 @@ int uev_run(uev_ctx_t *ctx, int flags) } for (i = 0; ctx->running && i < nfds; i++) { - uint64_t exp; - uint32_t events; struct signalfd_siginfo fdsi; + uint32_t events; + uint64_t exp; ssize_t sz = sizeof(fdsi); w = (uev_t *)ee[i].data.ptr; diff --git a/tests/active.c b/tests/active.c index 640e838..7f1c9ad 100644 --- a/tests/active.c +++ b/tests/active.c @@ -38,8 +38,8 @@ static void cb(uev_t *w, void *arg, int events) int main(void) { - uev_ctx_t ctx; struct timeval tomorrow; + uev_ctx_t ctx; gettimeofday(&tomorrow, NULL); tomorrow.tv_sec += 24 * 60 * 60; diff --git a/tests/cronrun.c b/tests/cronrun.c index 80d6646..464baab 100644 --- a/tests/cronrun.c +++ b/tests/cronrun.c @@ -33,8 +33,8 @@ struct timeval tv; static void cron_job(uev_t *w, void *arg, int events) { - static int laps = 3; struct timeval now; + static int laps = 3; if (UEV_ERROR == events) fprintf(stderr, "cron watcher failed, ignoring ...\n"); @@ -54,10 +54,10 @@ static void cron_job(uev_t *w, void *arg, int events) int main(void) { - int rc; - uev_t cron_watcher; uev_ctx_t ctx; time_t when, interval; + uev_t cron; + int rc; uev_init(&ctx); @@ -68,7 +68,7 @@ int main(void) printf("Expected cron %s", ctime(&when)); interval = INTERVAL; - uev_cron_init(&ctx, &cron_watcher, cron_job, NULL, when, interval); + uev_cron_init(&ctx, &cron, cron_job, NULL, when, interval); rc = uev_run(&ctx, 0); fail_unless(result == 0); diff --git a/tests/signal.c b/tests/signal.c index b58cbf4..d915310 100644 --- a/tests/signal.c +++ b/tests/signal.c @@ -81,8 +81,8 @@ static void sigchld_cb(uev_t *w, void *arg, int events) static void work_cb(uev_t *w, void *arg, int events) { - int status = 0; - pid_t pid; + pid_t pid; + int status = 0; pid = fork(); if (-1 == pid) @@ -113,8 +113,8 @@ static void exit_cb(uev_t *w, void *arg, int events) int main(void) { - uev_t sigsegv_watcher, sigchld_watcher, timeout_watcher, deadline_watcher; uev_ctx_t ctx; + uev_t sigsegv_watcher, sigchld_watcher, timeout_watcher, deadline_watcher; /* Initialize libuEv */ uev_init(&ctx); diff --git a/tests/timer.c b/tests/timer.c index 5bc4d95..2487513 100644 --- a/tests/timer.c +++ b/tests/timer.c @@ -23,9 +23,9 @@ static void cb(uev_t *w, void *arg, int events) int main(void) { - int rc; - uev_t w; uev_ctx_t ctx; + uev_t w; + int rc; uev_init(&ctx); uev_timer_init(&ctx, &w, cb, NULL, TIMEOUT * 1000, 0);