From 61bfd3d459b1111ef66ab432429a6b6f45d9af27 Mon Sep 17 00:00:00 2001 From: Simon McVittie <smcv@collabora.com> Date: Fri, 10 May 2019 16:51:06 +0100 Subject: [PATCH] Add and fix some compiler warnings Signed-off-by: Simon McVittie <smcv@collabora.com> --- meson.build | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/wrap.c | 3 +-- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index d400fe01e..3ba6d0704 100644 --- a/meson.build +++ b/meson.build @@ -38,6 +38,74 @@ if version == 'auto' version = git_version_gen.stdout().strip() endif + +warning_cflags = [ + '-Wall', + '-Wextra', + '-Warray-bounds', + '-Wcast-align', + '-Wdeclaration-after-statement', + '-Wdouble-promotion', + '-Wduplicated-branches', + '-Wduplicated-cond', + '-Wformat-nonliteral', + '-Wformat-security', + '-Wformat=2', + '-Wimplicit-function-declaration', + '-Winit-self', + '-Winline', + '-Wjump-misses-init', + '-Wlogical-op', + '-Wmissing-declarations', + '-Wmissing-format-attribute', + '-Wmissing-include-dirs', + '-Wmissing-noreturn', + '-Wmissing-prototypes', + '-Wnested-externs', + '-Wnull-dereference', + '-Wold-style-definition', + '-Wpacked', + '-Wpointer-arith', + '-Wredundant-decls', + '-Wrestrict', + '-Wreturn-type', + '-Wshadow', + '-Wstrict-aliasing', + '-Wstrict-prototypes', + '-Wswitch-default', + '-Wswitch-enum', + '-Wundef', + '-Wunused-but-set-variable', + '-Wwrite-strings', +] +no_warning_cflags = [ + 'declaration-after-statement', + 'missing-field-initializers', + 'sign-compare', + 'unused-parameter', +] +# This trips some warnings in the libglnx subproject but not in +# pressure-vessel itself +project_warning_cflags = [ + '-Wsign-compare', +] + + +c_compiler = meson.get_compiler('c') +supported_warning_cflags = c_compiler.get_supported_arguments(warning_cflags) +add_global_arguments(supported_warning_cflags, language : 'c') + +foreach flag : no_warning_cflags + supported_no_warning_cflags = c_compiler.get_supported_arguments([ + '-Wno-error=' + flag, + '-Wno-' + flag, + ]) + add_global_arguments(supported_no_warning_cflags, language : 'c') +endforeach + +supported_warning_cflags = c_compiler.get_supported_arguments(project_warning_cflags) +add_project_arguments(supported_warning_cflags, language : 'c') + scripts = [ 'pressure-vessel-wrap.sh', 'pressure-vessel-test-ui', diff --git a/src/wrap.c b/src/wrap.c index 178918520..604b412b6 100644 --- a/src/wrap.c +++ b/src/wrap.c @@ -364,7 +364,7 @@ write_xauth (char *number, FILE *output) local_xa = *xa; if (local_xa.number) { - local_xa.number = "99"; + local_xa.number = (char *) "99"; local_xa.number_length = 2; } @@ -684,7 +684,6 @@ flatpak_run_add_session_dbus_args (FlatpakBwrap *app_bwrap) } else { - g_autofree char *user_runtime_dir = flatpak_get_real_xdg_runtime_dir (); struct stat statbuf; dbus_session_socket = g_build_filename (user_runtime_dir, "bus", NULL); -- GitLab