From 99ef6eb884861155c932437d4580e5da90eb94e6 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Tue, 25 Sep 2018 23:19:02 +0200 Subject: [PATCH] Remove __attribute__ ((unused)), use -Wno-unused-parameter instead The __attribute__ ((unused)) is useful sometimes to declare variables as intended to be unused, e.g. in callback functions. However, they tend to clutter up the code making hard to read. We therefore remove all uses of it and instead set -Wno-unused-parameter. Signed-off-by: Joachim Nilsson --- src/bench.c | 6 ++---- src/uev.c | 2 -- tests/Makefile.am | 2 +- tests/active.c | 2 +- tests/api.c | 2 +- tests/check.h | 2 -- tests/complete.c | 8 ++++---- tests/cronrun.c | 2 +- tests/signal.c | 9 ++++----- tests/timer.c | 2 +- 10 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/bench.c b/src/bench.c index d69ba52..8ae02ed 100644 --- a/src/bench.c +++ b/src/bench.c @@ -57,8 +57,6 @@ #include "uev.h" -#define UNUSED(arg) arg __attribute__ ((unused)) - typedef struct { int index; } myarg_t; @@ -70,7 +68,7 @@ static int *pipes; static uev_t *evio; static uev_t *evto; -static void read_cb(uev_t *w, void *arg, int UNUSED(events)) +static void read_cb(uev_t *w, void *arg, int events) { int idx, widx; u_char ch; @@ -96,7 +94,7 @@ static void read_cb(uev_t *w, void *arg, int UNUSED(events)) } } -static void timer_cb(uev_t UNUSED(*w), void UNUSED(*arg), int UNUSED(events)) +static void timer_cb(uev_t *w, void *arg, int events) { /* nop */ } diff --git a/src/uev.c b/src/uev.c index d168775..8f976a6 100644 --- a/src/uev.c +++ b/src/uev.c @@ -33,8 +33,6 @@ #include "uev.h" -#define UNUSED(arg) arg __attribute__ ((unused)) - static int _init(uev_ctx_t *ctx, int close_old) { diff --git a/tests/Makefile.am b/tests/Makefile.am index 0506f60..f255f4b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -12,6 +12,6 @@ TESTS += timer check_PROGRAMS = $(TESTS) # Ignore warnings about unused result, in e.g. write() -CFLAGS = -W -Wall -Wextra -Wno-unused-result +CFLAGS = -W -Wall -Wextra -Wno-unused-result -Wno-unused-parameter CPPFLAGS = -D_GNU_SOURCE LDADD = -L../src ../src/libuev.la diff --git a/tests/active.c b/tests/active.c index 84a2b1b..640e838 100644 --- a/tests/active.c +++ b/tests/active.c @@ -12,7 +12,7 @@ uev_t timer3; uev_t cron1; uev_t cron2; -static void cb(uev_t *w, void *UNUSED(arg), int events) +static void cb(uev_t *w, void *arg, int events) { if (UEV_ERROR == events) fprintf(stderr, "timer watcher failed, ignoring ...\n"); diff --git a/tests/api.c b/tests/api.c index 43f6e74..af17ce6 100644 --- a/tests/api.c +++ b/tests/api.c @@ -3,7 +3,7 @@ uev_t timer, file; int counter = 10; -static void cb(uev_t *w, void *UNUSED(arg), int events) +static void cb(uev_t *w, void *arg, int events) { if (UEV_ERROR == events) fprintf(stderr, "timer watcher failed, ignoring ...\n"); diff --git a/tests/check.h b/tests/check.h index 9e6fe5d..4339919 100644 --- a/tests/check.h +++ b/tests/check.h @@ -9,8 +9,6 @@ #include "../src/uev.h" -#define UNUSED(arg) arg __attribute__ ((unused)) - #define fail_unless(test) \ do { \ if (!(test)) { \ diff --git a/tests/complete.c b/tests/complete.c index f19df4c..958fdd8 100644 --- a/tests/complete.c +++ b/tests/complete.c @@ -55,12 +55,12 @@ static void timeout_cb(uev_t *w, void *arg, int events) uev_exit(w->ctx); } -static void periodic_task(uev_t UNUSED(*w), void UNUSED(*arg), int UNUSED(events)) +static void periodic_task(uev_t *w, void *arg, int events) { fprintf(stderr, "|"); } -static void signal_cb(uev_t *w, void *UNUSED(arg), int events) +static void signal_cb(uev_t *w, void *arg, int events) { if (UEV_ERROR == events) { fprintf(stderr, "Signal watcher failed, unrecoverable error.\n"); @@ -70,7 +70,7 @@ static void signal_cb(uev_t *w, void *UNUSED(arg), int events) fprintf(stderr, w->signo == SIGINT ? "^Cv" : "^\v"); } -static void pipe_read_cb(uev_t *w, void UNUSED(*arg), int events) +static void pipe_read_cb(uev_t *w, void *arg, int events) { int len; char msg[50]; @@ -102,7 +102,7 @@ static void pipe_read_cb(uev_t *w, void UNUSED(*arg), int events) fprintf(stderr, "%.*s.%d ", len, msg, len); } -static void pipe_write_cb(uev_t *w, void *arg, int UNUSED(events)) +static void pipe_write_cb(uev_t *w, void *arg, int events) { my_t *my = arg; char *msg = "TESTING"; diff --git a/tests/cronrun.c b/tests/cronrun.c index c8a740a..80d6646 100644 --- a/tests/cronrun.c +++ b/tests/cronrun.c @@ -31,7 +31,7 @@ int result = -1; struct timeval tv; -static void cron_job(uev_t *w, void *UNUSED(arg), int events) +static void cron_job(uev_t *w, void *arg, int events) { static int laps = 3; struct timeval now; diff --git a/tests/signal.c b/tests/signal.c index c41924c..b58cbf4 100644 --- a/tests/signal.c +++ b/tests/signal.c @@ -33,7 +33,6 @@ #include #include -#define UNUSED(arg) arg __attribute__ ((unused)) #define DO_SEGFAULT 1 typedef struct { @@ -66,13 +65,13 @@ static int callback(arg_t *arg, int event, void *foo) return 42; } -static void sigsegv_cb(uev_t *UNUSED(w), void *UNUSED(arg), int UNUSED(events)) +static void sigsegv_cb(uev_t *w, void *arg, int events) { warnx("PID %d caused segfault.", getpid()); exit(-1); } -static void sigchld_cb(uev_t *UNUSED(w), void *UNUSED(arg), int UNUSED(events)) +static void sigchld_cb(uev_t *w, void *arg, int events) { pid_t pid = waitpid(-1, NULL, WNOHANG); @@ -80,7 +79,7 @@ static void sigchld_cb(uev_t *UNUSED(w), void *UNUSED(arg), int UNUSED(events)) warnx("PID %d exited, bye.", pid); } -static void work_cb(uev_t *UNUSED(w), void *arg, int UNUSED(events)) +static void work_cb(uev_t *w, void *arg, int events) { int status = 0; pid_t pid; @@ -106,7 +105,7 @@ static void work_cb(uev_t *UNUSED(w), void *arg, int UNUSED(events)) printf("Child did not exit normally!\n"); } -static void exit_cb(uev_t *w, void *UNUSED(arg), int UNUSED(events)) +static void exit_cb(uev_t *w, void *arg, int events) { printf("Process deadline reached, exiting!\n"); uev_exit(w->ctx); diff --git a/tests/timer.c b/tests/timer.c index b287ea8..5bc4d95 100644 --- a/tests/timer.c +++ b/tests/timer.c @@ -7,7 +7,7 @@ int result = -1; struct timeval start; -static void cb(uev_t *w, void *UNUSED(arg), int events) +static void cb(uev_t *w, void *arg, int events) { struct timeval now;