From 5445d8aad0112dab3ed798c39bf6b22f2a4eebd1 Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 28 Feb 2019 23:15:34 +0100 Subject: [PATCH] meson: enable more compiler warnings --- backend/session/logind.c | 2 +- backend/wayland/wl_seat.c | 2 +- examples/input-method.c | 4 ++-- examples/text-input.c | 2 +- meson.build | 35 ++++++++++++++++++++++++----------- render/gles2/renderer.c | 2 +- xwayland/sockets.c | 8 ++++---- 7 files changed, 34 insertions(+), 21 deletions(-) diff --git a/backend/session/logind.c b/backend/session/logind.c index 0bacfbcd..8f4e328d 100644 --- a/backend/session/logind.c +++ b/backend/session/logind.c @@ -440,7 +440,7 @@ static bool add_signal_matches(struct logind_session *session) { int ret; char str[256]; - const char *fmt = "type='signal'," + const char fmt[] = "type='signal'," "sender='org.freedesktop.login1'," "interface='org.freedesktop.login1.%s'," "member='%s'," diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c index 1229a0ac..6c8eb4f3 100644 --- a/backend/wayland/wl_seat.c +++ b/backend/wayland/wl_seat.c @@ -194,7 +194,7 @@ static void keyboard_handle_keymap(void *data, struct wl_keyboard *wl_keyboard, // TODO: set keymap } -static uint32_t get_current_time_msec() { +static uint32_t get_current_time_msec(void) { struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); return now.tv_nsec / 1000; diff --git a/examples/input-method.c b/examples/input-method.c index 4e375306..9276e159 100644 --- a/examples/input-method.c +++ b/examples/input-method.c @@ -176,7 +176,7 @@ static void timer_arm(unsigned seconds) { } } -static void do_updates() { +static void do_updates(void) { printf("Update %d\n", update_stage); switch (update_stage) { case 0: @@ -240,7 +240,7 @@ static void do_updates() { }; } -static void handle_timer() { +static void handle_timer(void) { printf("Timer dispatched at %d\n", update_stage); do_updates(); } diff --git a/examples/text-input.c b/examples/text-input.c index 3ccd99a0..ac3c8a44 100644 --- a/examples/text-input.c +++ b/examples/text-input.c @@ -102,7 +102,7 @@ static size_t utf8_offset(char *utf8_str, size_t byte_offset) { } // TODO: would be nicer to have this text display inside the window -static void show_status() { +static void show_status(void) { printf("State %d:", serial); if (!enabled) { printf(" disabled"); diff --git a/meson.build b/meson.build index 6f10ccdf..304e6330 100644 --- a/meson.build +++ b/meson.build @@ -16,16 +16,31 @@ project( # for a reference about clean library versioning. so_version = ['1', '2', '0'] -add_project_arguments( - [ - '-DWLR_SRC_DIR="@0@"'.format(meson.current_source_dir()), - '-DWLR_USE_UNSTABLE', +add_project_arguments([ + '-DWLR_SRC_DIR="@0@"'.format(meson.current_source_dir()), + '-DWLR_USE_UNSTABLE', +], language: 'c') - '-Wno-unused-parameter', - '-Wundef', - ], - language: 'c', -) +cc = meson.get_compiler('c') + +add_project_arguments(cc.get_supported_arguments([ + '-Wundef', + '-Wlogical-op', + '-Wmissing-include-dirs', + '-Wold-style-definition', + '-Wpointer-arith', + '-Winit-self', + '-Wstrict-prototypes', + '-Wredundant-decls', + '-Wimplicit-fallthrough=2', + '-Wendif-labels', + '-Wstrict-aliasing=2', + '-Woverflow', + + '-Wno-missing-braces', + '-Wno-missing-field-initializers', + '-Wno-unused-parameter', +]), language: 'c') conf_data = configuration_data() conf_data.set10('WLR_HAS_LIBCAP', false) @@ -38,8 +53,6 @@ conf_data.set10('WLR_HAS_XCB_ICCCM', false) wlr_inc = include_directories('.', 'include') -cc = meson.get_compiler('c') - # Clang complains about some zeroed initializer lists (= {0}), even though they # are valid if cc.get_id() == 'clang' diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 50689ad4..3409d144 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -312,7 +312,7 @@ static bool gles2_read_pixels(struct wlr_renderer *wlr_renderer, glGetError(); // Clear the error flag - unsigned char *p = data + dst_y * stride; + unsigned char *p = (unsigned char *)data + dst_y * stride; uint32_t pack_stride = width * fmt->bpp / 8; if (pack_stride == stride && dst_x == 0 && flags != NULL) { // Under these particular conditions, we can read the pixels with only diff --git a/xwayland/sockets.c b/xwayland/sockets.c index f90e3ca4..6360745f 100644 --- a/xwayland/sockets.c +++ b/xwayland/sockets.c @@ -14,11 +14,11 @@ #include #include "sockets.h" -static const char *lock_fmt = "/tmp/.X%d-lock"; -static const char *socket_dir = "/tmp/.X11-unix"; -static const char *socket_fmt = "/tmp/.X11-unix/X%d"; +static const char lock_fmt[] = "/tmp/.X%d-lock"; +static const char socket_dir[] = "/tmp/.X11-unix"; +static const char socket_fmt[] = "/tmp/.X11-unix/X%d"; #ifndef __linux__ -static const char *socket_fmt2 = "/tmp/.X11-unix/X%d_"; +static const char socket_fmt2[] = "/tmp/.X11-unix/X%d_"; #endif bool set_cloexec(int fd, bool cloexec) {