From 02d579d7571a25947a46f0c1d149dc0d90269e17 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Mon, 21 Sep 2020 10:02:22 +0000 Subject: [PATCH 1/3] build: Enable unused warnings in C The goal is to be free of unused X class of problems. For this, CI and any "serious" builds will fail on warnings. Debug builds, used in development, will warn by default but not fail. In addition, the 'strict' build option is added for when the debug build should fail on unused warnings as well. --- meson.build | 12 +++++++++++- meson_options.txt | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index d8e0e1bb..80b85f81 100644 --- a/meson.build +++ b/meson.build @@ -26,7 +26,7 @@ add_project_arguments( '-Wold-style-definition', '-Wredundant-decls', '-Wstrict-prototypes', - '-Wunused-function', + '-Wunused', ], language: 'c' ) @@ -38,6 +38,16 @@ conf_data = configuration_data() if get_option('buildtype').startswith('debug') add_project_arguments('-DDEBUG=1', language : 'c') endif + +if get_option('strict') + add_project_arguments( + [ + '-Werror=unused', + ], + language: 'c' + ) +endif + if get_option('buildtype') != 'plain' add_project_arguments('-fstack-protector-strong', language: 'c') endif diff --git a/meson_options.txt b/meson_options.txt index 180f12f3..bb68374d 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -10,3 +10,7 @@ option('tests', option('legacy', type: 'boolean', value: false, description: 'Build with Deban Buster versions of dependencies') + +option('strict', + type: 'boolean', value: true, + description: 'Turn more warnings into errors') From af00d74f71ac411d7cfe2de023b0cc30528552b8 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Thu, 3 Dec 2020 15:26:28 +0000 Subject: [PATCH 2/3] build: Enable wformat to remove warnings about missing wformat --- meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/meson.build b/meson.build index 80b85f81..a00bae53 100644 --- a/meson.build +++ b/meson.build @@ -21,6 +21,7 @@ add_project_arguments( '-Werror=int-conversion', '-Wformat-nonliteral', '-Wformat-security', + '-Wformat', '-Winit-self', '-Wmaybe-uninitialized', '-Wold-style-definition', From 2796362d348124cde1e20223a73ac70f42fdc03d Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Thu, 3 Dec 2020 15:26:54 +0000 Subject: [PATCH 3/3] build: Fail on any C warnings when strict --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index a00bae53..1adf7489 100644 --- a/meson.build +++ b/meson.build @@ -43,7 +43,7 @@ endif if get_option('strict') add_project_arguments( [ - '-Werror=unused', + '-Werror', ], language: 'c' )