diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2013-10-25 11:50:31 +0100 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2013-10-25 18:00:07 +0100 |
commit | ec466f400d79e58ac655919bf7c3047909c4aecd (patch) | |
tree | 6c88e16e22b4f1ae3b0558cf481dee047f1c167e | |
parent | 3da175cc6cd81eeccbef602197d10813dadea0c9 (diff) |
build: Disable some GCC warnings for generated C code
The GCC warning spew which results from Vala’s non-perfect generated C
code is distracting and can mask genuine warnings from valac or GCC.
This patch adds some #pragmas in warnings.h which disable as many of these
warnings as possible. Unfortunately some of the warnings are for const
qualifier discards and passing parameters of the wrong type, which (as far
as I know) can’t be disabled.
In any case, this patch eliminates GCC warnings for several C files, which is
better than nothing.
Note that warnings.h should only be included in build targets which compile
only Vala, and don’t compile any non-generated C code. Non-generated C code
should always be compiled with all warnings enabled, to catch legitimate
errors. See the comment at the top of warnings.h.
https://bugzilla.gnome.org/show_bug.cgi?id=710869
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | backends/eds/Makefile.am | 1 | ||||
-rw-r--r-- | backends/eds/lib/Makefile.am | 5 | ||||
-rw-r--r-- | backends/key-file/Makefile.am | 1 | ||||
-rw-r--r-- | backends/libsocialweb/Makefile.am | 1 | ||||
-rw-r--r-- | backends/libsocialweb/lib/Makefile.am | 5 | ||||
-rw-r--r-- | backends/ofono/Makefile.am | 1 | ||||
-rw-r--r-- | backends/telepathy/Makefile.am | 1 | ||||
-rw-r--r-- | backends/telepathy/lib/Makefile.am | 6 | ||||
-rw-r--r-- | backends/tracker/Makefile.am | 1 | ||||
-rw-r--r-- | backends/tracker/lib/Makefile.am | 1 | ||||
-rw-r--r-- | folks/Makefile.am | 11 | ||||
-rw-r--r-- | folks/warnings.h | 85 | ||||
-rw-r--r-- | tests/eds/Makefile.am | 1 | ||||
-rw-r--r-- | tests/folks/Makefile.am | 1 | ||||
-rw-r--r-- | tests/key-file/Makefile.am | 1 | ||||
-rw-r--r-- | tests/lib/eds/Makefile.am | 5 | ||||
-rw-r--r-- | tests/lib/key-file/Makefile.am | 5 | ||||
-rw-r--r-- | tests/lib/libsocialweb/Makefile.am | 5 | ||||
-rw-r--r-- | tests/lib/telepathy/Makefile.am | 5 | ||||
-rw-r--r-- | tests/lib/tracker/Makefile.am | 5 | ||||
-rw-r--r-- | tests/libsocialweb/Makefile.am | 1 | ||||
-rw-r--r-- | tests/telepathy/Makefile.am | 1 | ||||
-rw-r--r-- | tests/tracker/Makefile.am | 1 | ||||
-rw-r--r-- | tools/Makefile.am | 1 | ||||
-rw-r--r-- | tools/inspect/Makefile.am | 1 |
26 files changed, 153 insertions, 0 deletions
@@ -23,6 +23,7 @@ Bugs fixed: • Avoid useless string copies when normalizing phone numbers, and make the implementation respect the algorithm described in http://blog.barisione.org/2010-06/handling-phone-numbers +• Bug 710869 — Disable some GCC warnings for generated C code API changes: diff --git a/backends/eds/Makefile.am b/backends/eds/Makefile.am index af242fff..db576f41 100644 --- a/backends/eds/Makefile.am +++ b/backends/eds/Makefile.am @@ -34,6 +34,7 @@ eds_la_CPPFLAGS = \ -I$(top_srcdir)/backends/eds/lib \ -I$(top_srcdir)/backends/eds/lib/folks \ -include $(CONFIG_HEADER) \ + -include $(top_srcdir)/folks/warnings.h \ -DPACKAGE_DATADIR=\"$(pkgdatadir)\" \ -DBACKEND_NAME=\"$(BACKEND_NAME)\" \ -DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \ diff --git a/backends/eds/lib/Makefile.am b/backends/eds/lib/Makefile.am index f53cdc73..1dc88e04 100644 --- a/backends/eds/lib/Makefile.am +++ b/backends/eds/lib/Makefile.am @@ -54,6 +54,11 @@ libfolks_eds_la_VALAFLAGS = \ -H folks/folks-eds.h \ $(NULL) +libfolks_eds_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -include $(top_srcdir)/folks/warnings.h \ + $(NULL) + libfolks_eds_la_CFLAGS = \ $(AM_CFLAGS) \ $(ERROR_CFLAGS) \ diff --git a/backends/key-file/Makefile.am b/backends/key-file/Makefile.am index cfa02242..6fc21506 100644 --- a/backends/key-file/Makefile.am +++ b/backends/key-file/Makefile.am @@ -27,6 +27,7 @@ key_file_la_CPPFLAGS = \ -I$(top_srcdir) \ -I$(top_srcdir)/folks \ -include $(CONFIG_HEADER) \ + -include $(top_srcdir)/folks/warnings.h \ -DPACKAGE_DATADIR=\"$(pkgdatadir)\" \ -DBACKEND_NAME=\"$(BACKEND_NAME)\" \ -DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \ diff --git a/backends/libsocialweb/Makefile.am b/backends/libsocialweb/Makefile.am index 0f608d66..b33b4255 100644 --- a/backends/libsocialweb/Makefile.am +++ b/backends/libsocialweb/Makefile.am @@ -31,6 +31,7 @@ libsocialweb_la_CPPFLAGS = \ -I$(top_srcdir)/backends/libsocialweb/lib \ -I$(top_srcdir)/backends/libsocialweb/lib/folks \ -include $(CONFIG_HEADER) \ + -include $(top_srcdir)/folks/warnings.h \ -DPACKAGE_DATADIR=\"$(pkgdatadir)\" \ -DBACKEND_NAME=\"$(BACKEND_NAME)\" \ -DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \ diff --git a/backends/libsocialweb/lib/Makefile.am b/backends/libsocialweb/lib/Makefile.am index 5d6eceb7..be74f158 100644 --- a/backends/libsocialweb/lib/Makefile.am +++ b/backends/libsocialweb/lib/Makefile.am @@ -50,6 +50,11 @@ libfolks_libsocialweb_la_VALAFLAGS = \ -H folks/folks-libsocialweb.h \ $(NULL) +libfolks_libsocialweb_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -include $(top_srcdir)/folks/warnings.h \ + $(NULL) + libfolks_libsocialweb_la_CFLAGS = \ $(AM_CFLAGS) \ $(ERROR_CFLAGS) \ diff --git a/backends/ofono/Makefile.am b/backends/ofono/Makefile.am index 4151daf6..2f307bf3 100644 --- a/backends/ofono/Makefile.am +++ b/backends/ofono/Makefile.am @@ -34,6 +34,7 @@ ofono_la_CPPFLAGS = \ -I$(top_srcdir) \ -I$(top_srcdir)/folks \ -include $(CONFIG_HEADER) \ + -include $(top_srcdir)/folks/warnings.h \ -DPACKAGE_DATADIR=\"$(pkgdatadir)\" \ -DBACKEND_NAME=\"$(BACKEND_NAME)\" \ -DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \ diff --git a/backends/telepathy/Makefile.am b/backends/telepathy/Makefile.am index d22d9697..44094ae8 100644 --- a/backends/telepathy/Makefile.am +++ b/backends/telepathy/Makefile.am @@ -34,6 +34,7 @@ telepathy_la_CPPFLAGS = \ -I$(top_srcdir)/backends/telepathy/lib \ -I$(top_srcdir)/backends/telepathy/lib/folks \ -include $(CONFIG_HEADER) \ + -include $(top_srcdir)/folks/warnings.h \ -DPACKAGE_DATADIR=\"$(pkgdatadir)\" \ -DBACKEND_NAME=\"$(BACKEND_NAME)\" \ -DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \ diff --git a/backends/telepathy/lib/Makefile.am b/backends/telepathy/lib/Makefile.am index 1539084c..2f0b9c42 100644 --- a/backends/telepathy/lib/Makefile.am +++ b/backends/telepathy/lib/Makefile.am @@ -123,6 +123,7 @@ libtp_zeitgeist_dummy_la_CFLAGS = \ libtp_zeitgeist_la_CPPFLAGS = \ $(AM_CPPFLAGS) \ + -include $(top_srcdir)/folks/warnings.h \ -DABS_TOP_SRCDIR=\"${abs_top_srcdir}\" \ -DABS_TOP_BUILDDIR=\"${abs_top_builddir}\" \ -DPKGLIBEXECDIR=\"${pkglibexecdir}\" \ @@ -238,6 +239,11 @@ else libfolks_telepathy_la_VALAFLAGS += --pkg tp-zeitgeist-dummy endif +libfolks_telepathy_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -include $(top_srcdir)/folks/warnings.h \ + $(NULL) + libfolks_telepathy_la_CFLAGS = \ $(AM_CFLAGS) \ $(CODE_COVERAGE_CFLAGS) \ diff --git a/backends/tracker/Makefile.am b/backends/tracker/Makefile.am index fc8ff0bd..b8f399ae 100644 --- a/backends/tracker/Makefile.am +++ b/backends/tracker/Makefile.am @@ -32,6 +32,7 @@ tracker_la_CPPFLAGS = \ -I$(top_srcdir)/backends/tracker/lib \ -I$(top_srcdir)/backends/tracker/lib/folks \ -include $(CONFIG_HEADER) \ + -include $(top_srcdir)/folks/warnings.h \ -DPACKAGE_DATADIR=\"$(pkgdatadir)\" \ -DBACKEND_NAME=\"$(BACKEND_NAME)\" \ -DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \ diff --git a/backends/tracker/lib/Makefile.am b/backends/tracker/lib/Makefile.am index c0d22b48..de878f8a 100644 --- a/backends/tracker/lib/Makefile.am +++ b/backends/tracker/lib/Makefile.am @@ -37,6 +37,7 @@ libfolks_tracker_la_CPPFLAGS = \ -I$(top_srcdir) \ -I$(top_srcdir)/folks \ -include $(CONFIG_HEADER) \ + -include $(top_srcdir)/folks/warnings.h \ -DPACKAGE_DATADIR=\"$(pkgdatadir)\" \ -DBACKEND_NAME=\"$(BACKEND_NAME)\" \ -DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \ diff --git a/folks/Makefile.am b/folks/Makefile.am index 29833bc8..e58d8273 100644 --- a/folks/Makefile.am +++ b/folks/Makefile.am @@ -38,6 +38,11 @@ if ENABLE_PROFILING libfolks_internal_la_VALAFLAGS += --define=ENABLE_PROFILING endif +libfolks_internal_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -include $(top_srcdir)/folks/warnings.h \ + $(NULL) + libfolks_internal_la_CFLAGS = \ $(AM_CFLAGS) \ $(ERROR_CFLAGS) \ @@ -124,6 +129,11 @@ libfolks_la_VALAFLAGS = \ $(EDS_FLAGS) \ $(NULL) +libfolks_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -include $(top_srcdir)/folks/warnings.h \ + $(NULL) + libfolks_la_CFLAGS = \ $(AM_CFLAGS) \ $(CODE_COVERAGE_CFLAGS) \ @@ -171,6 +181,7 @@ EXTRA_DIST = \ $(pkgconfig_in) \ build-conf.vapi \ redeclare-internal-api.h \ + warnings.h \ $(NULL) CLEANFILES = diff --git a/folks/warnings.h b/folks/warnings.h new file mode 100644 index 00000000..15a922d8 --- /dev/null +++ b/folks/warnings.h @@ -0,0 +1,85 @@ +/* + * warnings - a set of gcc pragmas to disable warnings in Vala-generated C code + * + * Copyright © 2013 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + * + * Authors: + * Philip Withnall <philip.withnall@collabora.co.uk> + */ + +#ifndef FOLKS_WARNINGS_H +#define FOLKS_WARNINGS_H + +/* The following pragmas disable various GCC warnings which frequently arise + * from C code generated by Vala. Fixing the code generator to eliminate these + * warnings (especially the first few) is very low on the Vala developers' + * priority list, so for now we have to live with them disabled. + * + * The warnings nearer the end of the list are a little more specific and + * important, and bugs have been filed (and referenced below) to try and get + * the code generator fixed so we can remove the pragmas. + * + * This file should be included using + * *_CPPFLAGS += -include $(top_srcdir)/folks/warnings.h + * in every build target which compiles only Vala source files. Targets which + * compile both Vala and (non-generated) C should *not* include this file, so + * that genuine warnings in the C code are caught. */ + +/* Vala likes to duplicate function declarations at the top of every C file. + * They're all identical, so not a problem, but GCC should shut up about + * them. */ +#pragma GCC diagnostic ignored "-Wredundant-decls" + +/* Vala continually sets variabeles which it never later uses. */ +#pragma GCC diagnostic ignored "-Wunused-but-set-variable" + +/* Vala continually generates unused temporary variables. */ +#pragma GCC diagnostic ignored "-Wunused-variable" + +/* Vala sometimes generates unused utility functions. */ +#pragma GCC diagnostic ignored "-Wunused-function" + +/* Vala sometimes generates labels it doesn't use when doing async state + * machines and error handling. */ +#pragma GCC diagnostic ignored "-Wunused-label" + +/* Vala misses off the braces in nested static struct initialisations */ +#pragma GCC diagnostic ignored "-Wmissing-braces" + +/* Vala warns us about using deprecated functions from other namespaces, but + * handily doesn't warn about using deprecated functions internally. */ +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + +/* Vala likes putting format literals through temporary variables. */ +#pragma GCC diagnostic ignored "-Wformat-nonliteral" + +/* Vala often doesn't cast to the right parent class or interface for method + * calls. Disabling -Wcast-qual doesn't seem to achieve anything, but we might + * as well try. + * + * See: https://bugzilla.gnome.org/show_bug.cgi?id=652553 + * and: https://bugzilla.gnome.org/show_bug.cgi?id=710863 + * and: https://bugzilla.gnome.org/show_bug.cgi?id=710865 */ +#pragma GCC diagnostic ignored "-Wcast-qual" + +/* Vala can't emit the G_GNUC_PRINTF function attribute. + * + * See: https://bugzilla.gnome.org/show_bug.cgi?id=710862 */ +#pragma GCC diagnostic ignored "-Wsuggest-attribute=format" + +#endif diff --git a/tests/eds/Makefile.am b/tests/eds/Makefile.am index 2a367ec9..5f3f590d 100644 --- a/tests/eds/Makefile.am +++ b/tests/eds/Makefile.am @@ -20,6 +20,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/tests/lib \ -I$(top_srcdir)/tests/lib/eds \ -include $(CONFIG_HEADER) \ + -include $(top_srcdir)/folks/warnings.h \ $(NULL) LDADD = \ diff --git a/tests/folks/Makefile.am b/tests/folks/Makefile.am index 95f04932..0856529e 100644 --- a/tests/folks/Makefile.am +++ b/tests/folks/Makefile.am @@ -13,6 +13,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/tests/lib/telepathy \ -I$(top_srcdir)/tests/lib/telepathy/contactlist \ -include $(CONFIG_HEADER) \ + -include $(top_srcdir)/folks/warnings.h \ $(NULL) LDADD = \ diff --git a/tests/key-file/Makefile.am b/tests/key-file/Makefile.am index b10e1c46..32ab4593 100644 --- a/tests/key-file/Makefile.am +++ b/tests/key-file/Makefile.am @@ -10,6 +10,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/tests/lib \ -I$(top_srcdir)/tests/lib/key-file \ -include $(CONFIG_HEADER) \ + -include $(top_srcdir)/folks/warnings.h \ $(NULL) LDADD = \ diff --git a/tests/lib/eds/Makefile.am b/tests/lib/eds/Makefile.am index a09beafb..ab426735 100644 --- a/tests/lib/eds/Makefile.am +++ b/tests/lib/eds/Makefile.am @@ -29,6 +29,11 @@ libeds_test_la_SOURCES = \ test-case.vala \ $(NULL) +libeds_test_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -include $(top_srcdir)/folks/warnings.h \ + $(NULL) + libeds_test_la_CFLAGS = \ $(AM_CFLAGS) \ $(ERROR_CFLAGS) \ diff --git a/tests/lib/key-file/Makefile.am b/tests/lib/key-file/Makefile.am index 6bb4844e..1123eac2 100644 --- a/tests/lib/key-file/Makefile.am +++ b/tests/lib/key-file/Makefile.am @@ -21,6 +21,11 @@ libkf_test_la_SOURCES = \ test-case.vala \ $(NULL) +libkf_test_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -include $(top_srcdir)/folks/warnings.h \ + $(NULL) + libkf_test_la_CFLAGS = \ -I$(top_srcdir) \ -I$(top_srcdir)/tests/lib \ diff --git a/tests/lib/libsocialweb/Makefile.am b/tests/lib/libsocialweb/Makefile.am index 311c5cc9..d55d4394 100644 --- a/tests/lib/libsocialweb/Makefile.am +++ b/tests/lib/libsocialweb/Makefile.am @@ -26,6 +26,11 @@ libsocialweb_test_la_SOURCES = \ test-case.vala \ $(NULL) +libsocialweb_test_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -include $(top_srcdir)/folks/warnings.h \ + $(NULL) + libsocialweb_test_la_CFLAGS = \ $(AM_CFLAGS) \ $(ERROR_CFLAGS) \ diff --git a/tests/lib/telepathy/Makefile.am b/tests/lib/telepathy/Makefile.am index 19d72e26..b3c089ca 100644 --- a/tests/lib/telepathy/Makefile.am +++ b/tests/lib/telepathy/Makefile.am @@ -30,6 +30,11 @@ libtpf_test_la_SOURCES = \ test-case.vala \ $(NULL) +libtpf_test_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -include $(top_srcdir)/folks/warnings.h \ + $(NULL) + libtpf_test_la_CFLAGS = \ $(AM_CFLAGS) \ $(ERROR_CFLAGS) \ diff --git a/tests/lib/tracker/Makefile.am b/tests/lib/tracker/Makefile.am index 7da67014..d09256a5 100644 --- a/tests/lib/tracker/Makefile.am +++ b/tests/lib/tracker/Makefile.am @@ -26,6 +26,11 @@ libtracker_test_la_SOURCES = \ test-case.vala \ $(NULL) +libtracker_test_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -include $(top_srcdir)/folks/warnings.h \ + $(NULL) + libtracker_test_la_CFLAGS = \ $(AM_CFLAGS) \ $(ERROR_CFLAGS) \ diff --git a/tests/libsocialweb/Makefile.am b/tests/libsocialweb/Makefile.am index c1f2e47e..36958f0a 100644 --- a/tests/libsocialweb/Makefile.am +++ b/tests/libsocialweb/Makefile.am @@ -14,6 +14,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/tests/lib \ -I$(top_srcdir)/tests/lib/libsocialweb \ -include $(CONFIG_HEADER) \ + -include $(top_srcdir)/folks/warnings.h \ $(NULL) LDADD = \ diff --git a/tests/telepathy/Makefile.am b/tests/telepathy/Makefile.am index 5eda26d5..88d6992e 100644 --- a/tests/telepathy/Makefile.am +++ b/tests/telepathy/Makefile.am @@ -16,6 +16,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/tests/lib/telepathy \ -I$(top_srcdir)/tests/lib/telepathy/contactlist \ -include $(CONFIG_HEADER) \ + -include $(top_srcdir)/folks/warnings.h \ $(NULL) LDADD = \ diff --git a/tests/tracker/Makefile.am b/tests/tracker/Makefile.am index 44db0261..2bfdc9f8 100644 --- a/tests/tracker/Makefile.am +++ b/tests/tracker/Makefile.am @@ -19,6 +19,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/tests/lib \ -I$(top_srcdir)/tests/lib/tracker \ -include $(CONFIG_HEADER) \ + -include $(top_srcdir)/folks/warnings.h \ $(NULL) LDADD = \ diff --git a/tools/Makefile.am b/tools/Makefile.am index 3dcd01fc..615fb17e 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -25,6 +25,7 @@ folks_import_SOURCES = \ folks_import_CPPFLAGS = \ $(AM_CPPFLAGS) \ -include $(CONFIG_HEADER) \ + -include $(top_srcdir)/folks/warnings.h \ -DLOCALE_DIR=\"$(localedir)\" \ -I$(top_srcdir) \ -I$(top_srcdir)/folks \ diff --git a/tools/inspect/Makefile.am b/tools/inspect/Makefile.am index 05f27d7b..e45d1ecb 100644 --- a/tools/inspect/Makefile.am +++ b/tools/inspect/Makefile.am @@ -38,6 +38,7 @@ folks_inspect_LDADD = \ folks_inspect_CPPFLAGS = \ $(AM_CPPFLAGS) \ -include $(CONFIG_HEADER) \ + -include $(top_srcdir)/folks/warnings.h \ -DLOCALE_DIR=\"$(localedir)\" \ -I$(top_srcdir) \ -I$(top_srcdir)/folks \ |