From c34317dc2cbb1d636fd00bd201033acb1ae22016 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sun, 28 Aug 2022 16:27:01 +0200 Subject: make compilers happier --- src/CMakeLists.txt | 2 +- src/compiler.h | 10 ++++++++++ src/file.c | 4 +++- src/server.c | 8 +++++--- src/signal.h | 4 +++- src/worker.c | 2 +- 6 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 src/compiler.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e565d78..0d3c7e9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,7 +5,7 @@ project(cimple VERSION 0.0.1 LANGUAGES C) if(MSVC) add_compile_options(/W4 /WX) else() - add_compile_options(-Wall -Wextra -Werror -Wno-error=unused-parameter) + add_compile_options(-Wall -Wextra -Werror) endif() add_compile_definitions(_GNU_SOURCE) diff --git a/src/compiler.h b/src/compiler.h new file mode 100644 index 0000000..de721d9 --- /dev/null +++ b/src/compiler.h @@ -0,0 +1,10 @@ +#ifndef __COMPILER_H__ +#define __COMPILER_H__ + +#ifdef __GNUC__ +#define UNUSED __attribute__((unused)) +#else +#define UNUSED +#endif + +#endif diff --git a/src/file.c b/src/file.c index 0273e71..a1ebb6d 100644 --- a/src/file.c +++ b/src/file.c @@ -1,4 +1,5 @@ #include "file.h" +#include "compiler.h" #include "log.h" #include @@ -7,7 +8,8 @@ #include #include -static int unlink_cb(const char *fpath, const struct stat *, int, struct FTW *) +static int unlink_cb(const char *fpath, UNUSED const struct stat *sb, UNUSED int typeflag, + UNUSED struct FTW *ftwbuf) { int ret = 0; diff --git a/src/server.c b/src/server.c index 6a4b73c..a84016e 100644 --- a/src/server.c +++ b/src/server.c @@ -1,5 +1,6 @@ #include "server.h" #include "ci_queue.h" +#include "compiler.h" #include "log.h" #include "msg.h" #include "signal.h" @@ -144,7 +145,7 @@ static int worker_requeue_run(struct server *server, struct ci_queue_entry *ci_r static int worker_iteration(struct server *server, int fd) { - struct ci_queue_entry *ci_run; + struct ci_queue_entry *ci_run = NULL; int ret = 0; ret = worker_dequeue_run(server, &ci_run); @@ -177,12 +178,13 @@ static int worker_thread(struct server *server, int fd) return ret; } -static int msg_new_worker_handler(struct server *server, int client_fd, const struct msg *) +static int msg_new_worker_handler(struct server *server, int client_fd, + UNUSED const struct msg *request) { return worker_thread(server, client_fd); } -static int msg_new_worker_parser(const struct msg *) +static int msg_new_worker_parser(UNUSED const struct msg *msg) { return 1; } diff --git a/src/signal.h b/src/signal.h index ac6da9d..d06ab6d 100644 --- a/src/signal.h +++ b/src/signal.h @@ -1,13 +1,15 @@ #ifndef __SIGNAL_H__ #define __SIGNAL_H__ +#include "compiler.h" + #include #include #include extern volatile sig_atomic_t global_stop_flag; -static void signal_handler(int) +static void signal_handler(UNUSED int signum) { global_stop_flag = 1; } diff --git a/src/worker.c b/src/worker.c index 3b48636..fbf609b 100644 --- a/src/worker.c +++ b/src/worker.c @@ -143,7 +143,7 @@ unknown_request: return msg_send(worker->fd, &response); } -int worker_main(struct worker *worker, int, char *[]) +int worker_main(struct worker *worker, UNUSED int argc, UNUSED char *argv[]) { int ret = 0; -- cgit v1.2.3