[folks] build: Disable some GCC warnings for generated C code
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] build: Disable some GCC warnings for generated C code
- Date: Fri, 25 Oct 2013 17:01:01 +0000 (UTC)
commit ec466f400d79e58ac655919bf7c3047909c4aecd
Author: Philip Withnall <philip withnall collabora co uk>
Date: Fri Oct 25 11:50:31 2013 +0100
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
NEWS | 1 +
backends/eds/Makefile.am | 1 +
backends/eds/lib/Makefile.am | 5 ++
backends/key-file/Makefile.am | 1 +
backends/libsocialweb/Makefile.am | 1 +
backends/libsocialweb/lib/Makefile.am | 5 ++
backends/ofono/Makefile.am | 1 +
backends/telepathy/Makefile.am | 1 +
backends/telepathy/lib/Makefile.am | 6 ++
backends/tracker/Makefile.am | 1 +
backends/tracker/lib/Makefile.am | 1 +
folks/Makefile.am | 11 ++++
folks/warnings.h | 85 +++++++++++++++++++++++++++++++++
tests/eds/Makefile.am | 1 +
tests/folks/Makefile.am | 1 +
tests/key-file/Makefile.am | 1 +
tests/lib/eds/Makefile.am | 5 ++
tests/lib/key-file/Makefile.am | 5 ++
tests/lib/libsocialweb/Makefile.am | 5 ++
tests/lib/telepathy/Makefile.am | 5 ++
tests/lib/tracker/Makefile.am | 5 ++
tests/libsocialweb/Makefile.am | 1 +
tests/telepathy/Makefile.am | 1 +
tests/tracker/Makefile.am | 1 +
tools/Makefile.am | 1 +
tools/inspect/Makefile.am | 1 +
26 files changed, 153 insertions(+), 0 deletions(-)
---
diff --git a/NEWS b/NEWS
index 2ad7b4f..061a6da 100644
--- a/NEWS
+++ b/NEWS
@@ -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 af242ff..db576f4 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 f53cdc7..1dc88e0 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 cfa0224..6fc2150 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 0f608d6..b33b425 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 5d6eceb..be74f15 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 4151daf..2f307bf 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 d22d969..44094ae 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 1539084..2f0b9c4 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 fc8ff0b..b8f399a 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 c0d22b4..de878f8 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 29833bc..e58d827 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 0000000..15a922d
--- /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 2a367ec..5f3f590 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 95f0493..0856529 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 b10e1c4..32ab459 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 a09beaf..ab42673 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 6bb4844..1123eac 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 311c5cc..d55d439 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 19d72e2..b3c089c 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 7da6701..d09256a 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 c1f2e47..36958f0 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 5eda26d..88d6992 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 44db026..2bfdc9f 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 3dcd01f..615fb17 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 05f27d7..e45d1ec 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 \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]