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 <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2018-09-25 23:19:02 +02:00
parent de89b6647d
commit 99ef6eb884
10 changed files with 15 additions and 22 deletions
+2 -4
View File
@@ -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 */
}
-2
View File
@@ -33,8 +33,6 @@
#include "uev.h"
#define UNUSED(arg) arg __attribute__ ((unused))
static int _init(uev_ctx_t *ctx, int close_old)
{
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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");
+1 -1
View File
@@ -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");
-2
View File
@@ -9,8 +9,6 @@
#include "../src/uev.h"
#define UNUSED(arg) arg __attribute__ ((unused))
#define fail_unless(test) \
do { \
if (!(test)) { \
+4 -4
View File
@@ -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";
+1 -1
View File
@@ -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;
+4 -5
View File
@@ -33,7 +33,6 @@
#include <sys/wait.h>
#include <unistd.h>
#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);
+1 -1
View File
@@ -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;