[glib/wip/cflags] build: Add set of standard -Werror=foo flags



commit a7dd5213f69bb06c496a8bd60033f3353b0552c1
Author: Colin Walters <walters verbum org>
Date:   Thu Nov 1 17:21:10 2012 -0400

    build: Add set of standard -Werror=foo flags
    
    We're not going to depend on gnome-common (I assume) so this patch
    nicks the systemd macro to test for compiler flags, and uses it to set
    a similar set of -Werror=foo as the gnome-common one does.
    
    See https://bugzilla.gnome.org/show_bug.cgi?id=608953
    See https://mail.gnome.org/archives/desktop-devel-list/2012-July/msg00100.html
    
    In particular, you can see several times that downstreams such as
    Debian have come in and fixed -Wformat-security bugs.  We should never
    let those get into tarballs, or even commits.

 configure.ac                          |   16 +-
 gio/Makefile.am                       |    1 +
 gio/gactiongroupexporter.c            |    2 +-
 gio/gapplicationimpl-dbus.c           |    2 +-
 gio/gdbusactiongroup-private.h        |   37 +++++
 gio/gdbusactiongroup.c                |    4 +-
 gio/gmenumodel.c                      |    4 +
 gio/gresource.c                       |    2 +-
 gio/gresourcefile.c                   |    2 +
 gio/gtestdbus.c                       |    2 +-
 gio/tests/gdbus-peer-object-manager.c |    3 +-
 gio/tests/gdbus-peer.c                |    2 +-
 gio/tests/gdbus-proxy.c               |    4 +-
 gio/tests/gdbus-test-codegen.c        |   14 +-
 gio/tests/proxy-test.c                |    5 +
 gio/tests/resources.c                 |    2 +-
 gio/tests/test-pipe-unix.c            |    1 +
 glib/Makefile.am                      |    1 +
 glib/gcharset.c                       |    2 +-
 glib/gcharsetprivate.h                |   33 ++++
 glib/gconvert.c                       |    2 +-
 glib/ggettext.c                       |    1 +
 glib/gslice.h                         |    4 +
 glib/gthread-posix.c                  |   10 +-
 glib/gutils.c                         |    3 +-
 glib/tests/1bit-mutex.c               |    6 +
 glib/tests/gdatetime.c                |    3 +-
 gobject/tests/Makefile.am             |    2 +-
 gobject/tests/param.c                 |    1 +
 gobject/tests/threadtests.c           |    2 +-
 m4macros/attributes.m4                |  288 +++++++++++++++++++++++++++++++++
 tests/gobject/Makefile.am             |    4 +-
 tests/libmoduletestplugin_a.c         |    6 +
 tests/libmoduletestplugin_b.c         |    8 +
 tests/refcount/closures.c             |    1 +
 tests/refcount/properties3.c          |    1 +
 tests/refcount/properties4.c          |    1 +
 tests/testgdate.c                     |    3 +-
 tests/testgdateparser.c               |    3 +-
 tests/unicode-collate.c               |    4 +-
 40 files changed, 451 insertions(+), 41 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 5c112ea..dd193ea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -527,13 +527,6 @@ dnl when using libtool 2.x create libtool early, because it's used in configure
 m4_ifdef([LT_OUTPUT], [LT_OUTPUT])
 
 
-if test "x$GCC" = "xyes"; then
-  case " $CFLAGS " in
-  *[[\ \	]]-Wall[[\ \	]]*) ;;
-  *) CFLAGS="$CFLAGS -Wall" ;;
-  esac
-fi
-
 AS_IF([test "$glib_native_win32" = "yes"], [
   if test x$enable_static = xyes -a x$enable_shared = xyes; then
     AC_MSG_ERROR([Can not build both shared and static at the same time on Windows.])
@@ -3532,6 +3525,15 @@ fi
 
 AC_SUBST(GLIB_LINK_FLAGS)
 
+dnl Compiler flags; macro originates from systemd
+dnl See https://bugzilla.gnome.org/show_bug.cgi?id=608953
+CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
+   -Wall -Wstrict-prototypes -Werror=declaration-after-statement \
+   -Werror=missing-prototypes -Werror=implicit-function-declaration \
+   -Werror=pointer-arith -Werror=init-self -Werror=format-security \
+   -Werror=format=2 -Werror=missing-include-dirs])
+CFLAGS="$CFLAGS $with_cflags"
+
 #
 # Define variables corresponding to the correct include paths to use for
 # in-tree building.
diff --git a/gio/Makefile.am b/gio/Makefile.am
index cbafbf6..4a445a3 100644
--- a/gio/Makefile.am
+++ b/gio/Makefile.am
@@ -174,6 +174,7 @@ application_sources = \
 	gsimpleactiongroup.c			\
 	gremoteactiongroup.c			\
 	gactiongroupexporter.c			\
+	gdbusactiongroup-private.h		\
 	gdbusactiongroup.c			\
 	gaction.c				\
 	gsimpleaction.c				\
diff --git a/gio/gactiongroupexporter.c b/gio/gactiongroupexporter.c
index cc33d36..c906344 100644
--- a/gio/gactiongroupexporter.c
+++ b/gio/gactiongroupexporter.c
@@ -45,7 +45,7 @@
  * g_dbus_action_group_get() to obtain a #GDBusActionGroup.
  */
 
-G_GNUC_INTERNAL GVariant *
+static GVariant *
 g_action_group_describe_action (GActionGroup *action_group,
                                 const gchar  *name)
 {
diff --git a/gio/gapplicationimpl-dbus.c b/gio/gapplicationimpl-dbus.c
index 1248d0f..a2c90d1 100644
--- a/gio/gapplicationimpl-dbus.c
+++ b/gio/gapplicationimpl-dbus.c
@@ -37,7 +37,7 @@
 #include "gapplicationcommandline.h"
 #include "gdbusmethodinvocation.h"
 
-G_GNUC_INTERNAL gboolean
+static gboolean
 g_dbus_action_group_sync (GDBusActionGroup  *group,
                           GCancellable      *cancellable,
                           GError           **error);
diff --git a/gio/gdbusactiongroup-private.h b/gio/gdbusactiongroup-private.h
new file mode 100644
index 0000000..8c42b4d
--- /dev/null
+++ b/gio/gdbusactiongroup-private.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright  2010 Codethink Limited
+ * Copyright  2011 Canonical Limited
+ *
+ * This program 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 of the licence 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., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Ryan Lortie <desrt desrt ca>
+ */
+
+#ifndef __G_DBUS_ACTION_GROUP_PRIVATE_H__
+#define __G_DBUS_ACTION_GROUP_PRIVATE_H__
+
+#include "gdbusactiongroup.h"
+
+G_BEGIN_DECLS
+
+gboolean
+g_dbus_action_group_sync (GDBusActionGroup  *group,
+                          GCancellable      *cancellable,
+                          GError           **error);
+
+G_END_DECLS
+
+#endif 
diff --git a/gio/gdbusactiongroup.c b/gio/gdbusactiongroup.c
index b1c7649..b73b736 100644
--- a/gio/gdbusactiongroup.c
+++ b/gio/gdbusactiongroup.c
@@ -22,7 +22,7 @@
 
 #include "config.h"
 
-#include "gdbusactiongroup.h"
+#include "gdbusactiongroup-private.h"
 
 #include "gremoteactiongroup.h"
 #include "gdbusconnection.h"
@@ -92,7 +92,7 @@ action_info_free (gpointer user_data)
   g_slice_free (ActionInfo, info);
 }
 
-ActionInfo *
+static ActionInfo *
 action_info_new_from_iter (GVariantIter *iter)
 {
   const gchar *param_str;
diff --git a/gio/gmenumodel.c b/gio/gmenumodel.c
index 47860d2..f9cd826 100644
--- a/gio/gmenumodel.c
+++ b/gio/gmenumodel.c
@@ -195,6 +195,8 @@ typedef struct
 
 typedef GMenuLinkIterClass GMenuLinkHashIterClass;
 
+static GType g_menu_link_hash_iter_get_type (void);
+
 G_DEFINE_TYPE (GMenuLinkHashIter, g_menu_link_hash_iter, G_TYPE_MENU_LINK_ITER)
 
 static gboolean
@@ -249,6 +251,8 @@ typedef struct
 
 typedef GMenuAttributeIterClass GMenuAttributeHashIterClass;
 
+static GType g_menu_attribute_hash_iter_get_type (void);
+
 G_DEFINE_TYPE (GMenuAttributeHashIter, g_menu_attribute_hash_iter, G_TYPE_MENU_ATTRIBUTE_ITER)
 
 static gboolean
diff --git a/gio/gresource.c b/gio/gresource.c
index 26455c7..ad40a78 100644
--- a/gio/gresource.c
+++ b/gio/gresource.c
@@ -38,7 +38,7 @@ struct _GResource
   GvdbTable *table;
 };
 
-static void register_lazy_static_resources ();
+static void register_lazy_static_resources (void);
 
 G_DEFINE_BOXED_TYPE (GResource, g_resource, g_resource_ref, g_resource_unref)
 
diff --git a/gio/gresourcefile.c b/gio/gresourcefile.c
index e399e54..de26246 100644
--- a/gio/gresourcefile.c
+++ b/gio/gresourcefile.c
@@ -72,6 +72,8 @@ static void g_resource_file_file_iface_init (GFileIface *iface);
 static GFileAttributeInfoList *resource_writable_attributes = NULL;
 static GFileAttributeInfoList *resource_writable_namespaces = NULL;
 
+static GType _g_resource_file_enumerator_get_type (void);
+
 #define G_TYPE_RESOURCE_FILE_ENUMERATOR         (_g_resource_file_enumerator_get_type ())
 #define G_RESOURCE_FILE_ENUMERATOR(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_RESOURCE_FILE_ENUMERATOR, GResourceFileEnumerator))
 #define G_RESOURCE_FILE_ENUMERATOR_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_RESOURCE_FILE_ENUMERATOR, GResourceFileEnumeratorClass))
diff --git a/gio/gtestdbus.c b/gio/gtestdbus.c
index c2f91eb..6bb98cf 100644
--- a/gio/gtestdbus.c
+++ b/gio/gtestdbus.c
@@ -74,7 +74,7 @@ unref_on_idle (gpointer object)
   return FALSE;
 }
 
-gboolean
+static gboolean
 _g_object_unref_and_wait_weak_notify (gpointer object)
 {
   WeakNotifyData data;
diff --git a/gio/tests/gdbus-peer-object-manager.c b/gio/tests/gdbus-peer-object-manager.c
index 89537cc..7a19c71 100644
--- a/gio/tests/gdbus-peer-object-manager.c
+++ b/gio/tests/gdbus-peer-object-manager.c
@@ -39,6 +39,7 @@ typedef struct {
   GDBusInterfaceSkeletonClass parent_class;
 } MockInterfaceClass;
 
+static GType mock_interface_get_type (void);
 G_DEFINE_TYPE (MockInterface, mock_interface, G_TYPE_DBUS_INTERFACE_SKELETON);
 
 static void
@@ -84,7 +85,7 @@ mock_interface_get_info (GDBusInterfaceSkeleton *skeleton)
   return &interface_info;
 }
 
-GVariant *
+static GVariant *
 mock_interface_get_property (GDBusConnection *connection,
                              const gchar *sender,
                              const gchar *object_path,
diff --git a/gio/tests/gdbus-peer.c b/gio/tests/gdbus-peer.c
index 0435597..917c888 100644
--- a/gio/tests/gdbus-peer.c
+++ b/gio/tests/gdbus-peer.c
@@ -1682,7 +1682,7 @@ codegen_service_thread_func (gpointer user_data)
 }
 
 
-gboolean
+static gboolean
 codegen_quit_mainloop_timeout (gpointer data)
 {
   g_main_loop_quit (loop);
diff --git a/gio/tests/gdbus-proxy.c b/gio/tests/gdbus-proxy.c
index e614ed3..28ac86c 100644
--- a/gio/tests/gdbus-proxy.c
+++ b/gio/tests/gdbus-proxy.c
@@ -168,6 +168,8 @@ test_properties (GDBusProxy *proxy)
   GVariant *variant2;
   GVariant *result;
   gchar **names;
+  gchar *name_owner;
+  GDBusProxy *proxy2;
 
   error = NULL;
 
@@ -296,8 +298,6 @@ test_properties (GDBusProxy *proxy)
   g_assert (variant == NULL);
 
   /* Now test that G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES works - we need a new proxy for that */
-  gchar *name_owner;
-  GDBusProxy *proxy2;
   error = NULL;
   proxy2 = g_dbus_proxy_new_sync (g_dbus_proxy_get_connection (proxy),
                                   G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES,
diff --git a/gio/tests/gdbus-test-codegen.c b/gio/tests/gdbus-test-codegen.c
index 8af2ca6..4e8383a 100644
--- a/gio/tests/gdbus-test-codegen.c
+++ b/gio/tests/gdbus-test-codegen.c
@@ -699,6 +699,10 @@ static void
 check_bar_proxy (FooiGenBar *proxy,
                  GMainLoop  *thread_loop)
 {
+  const gchar *array_of_strings[3] = {"one", "two", NULL};
+  const gchar *array_of_strings_2[3] = {"one2", "two2", NULL};
+  const gchar *array_of_objpaths[3] = {"/one", "/one/two", NULL};
+  const gchar *array_of_bytestrings[3] = {"one\xff", "two\xff", NULL};
   guchar ret_val_byte;
   gboolean ret_val_boolean;
   gint16 ret_val_int16;
@@ -744,6 +748,9 @@ check_bar_proxy (FooiGenBar *proxy,
   gchar *val_finally_normal_name;
   GVariant *v;
   gchar *s;
+  const gchar *const *read_as;
+  const gchar *const *read_as2;
+  const gchar *const *read_as3;
 
   data = g_new0 (ClientData, 1);
   data->thread_loop = thread_loop;
@@ -838,10 +845,6 @@ check_bar_proxy (FooiGenBar *proxy,
   /* Try setting properties that requires memory management. This
    * is to exercise the paths that frees the references.
    */
-  const gchar *array_of_strings[3] = {"one", "two", NULL};
-  const gchar *array_of_strings_2[3] = {"one2", "two2", NULL};
-  const gchar *array_of_objpaths[3] = {"/one", "/one/two", NULL};
-  const gchar *array_of_bytestrings[3] = {"one\xff", "two\xff", NULL};
 
   g_object_set (proxy,
                 "s", "a string",
@@ -939,9 +942,6 @@ check_bar_proxy (FooiGenBar *proxy,
    * updates on them works as well (See comment for "property vfuncs"
    * in gio/gdbus-codegen/codegen.py for details)
    */
-  const gchar *const *read_as;
-  const gchar *const *read_as2;
-  const gchar *const *read_as3;
   read_as = foo_igen_bar_get_as (proxy);
   read_as2 = foo_igen_bar_get_as (proxy);
   g_assert_cmpint (g_strv_length ((gchar **) read_as), ==, 2);
diff --git a/gio/tests/proxy-test.c b/gio/tests/proxy-test.c
index 842e7d9..da0e837 100644
--- a/gio/tests/proxy-test.c
+++ b/gio/tests/proxy-test.c
@@ -94,6 +94,7 @@ typedef struct {
 
 static void g_test_proxy_resolver_iface_init (GProxyResolverInterface *iface);
 
+static GType _g_test_proxy_resolver_get_type (void);
 #define g_test_proxy_resolver_get_type _g_test_proxy_resolver_get_type
 G_DEFINE_TYPE_WITH_CODE (GTestProxyResolver, g_test_proxy_resolver, G_TYPE_OBJECT,
 			 G_IMPLEMENT_INTERFACE (G_TYPE_PROXY_RESOLVER,
@@ -210,6 +211,7 @@ typedef struct {
   GObjectClass parent_class;
 } GProxyBaseClass;
 
+static GType _g_proxy_base_get_type (void);
 #define g_proxy_base_get_type _g_proxy_base_get_type
 G_DEFINE_ABSTRACT_TYPE (GProxyBase, g_proxy_base, G_TYPE_OBJECT)
 
@@ -313,6 +315,7 @@ typedef GProxyBaseClass GProxyAClass;
 
 static void g_proxy_a_iface_init (GProxyInterface *proxy_iface);
 
+static GType _g_proxy_a_get_type (void);
 #define g_proxy_a_get_type _g_proxy_a_get_type
 G_DEFINE_TYPE_WITH_CODE (GProxyA, g_proxy_a, g_proxy_base_get_type (),
 			 G_IMPLEMENT_INTERFACE (G_TYPE_PROXY,
@@ -357,6 +360,7 @@ typedef GProxyBaseClass GProxyBClass;
 
 static void g_proxy_b_iface_init (GProxyInterface *proxy_iface);
 
+static GType _g_proxy_b_get_type (void);
 #define g_proxy_b_get_type _g_proxy_b_get_type
 G_DEFINE_TYPE_WITH_CODE (GProxyB, g_proxy_b, g_proxy_base_get_type (),
 			 G_IMPLEMENT_INTERFACE (G_TYPE_PROXY,
@@ -665,6 +669,7 @@ create_server (ServerData *data, GCancellable *cancellable)
 typedef GResolver GFakeResolver;
 typedef GResolverClass GFakeResolverClass;
 
+static GType g_fake_resolver_get_type (void);
 G_DEFINE_TYPE (GFakeResolver, g_fake_resolver, G_TYPE_RESOLVER)
 
 static void
diff --git a/gio/tests/resources.c b/gio/tests/resources.c
index d21513b..f7a7e83 100644
--- a/gio/tests/resources.c
+++ b/gio/tests/resources.c
@@ -487,7 +487,7 @@ test_uri_query_info (void)
   g_resource_unref (resource);
 }
 
-void
+static void
 test_uri_file (void)
 {
   GResource *resource;
diff --git a/gio/tests/test-pipe-unix.c b/gio/tests/test-pipe-unix.c
index 07f6198..4b348db 100644
--- a/gio/tests/test-pipe-unix.c
+++ b/gio/tests/test-pipe-unix.c
@@ -27,6 +27,7 @@
 #include <gio/gio.h>
 
 #include "test-io-stream.h"
+#include "test-pipe-unix.h"
 
 #ifdef G_OS_UNIX
 #   include <gio/gunixinputstream.h>
diff --git a/glib/Makefile.am b/glib/Makefile.am
index 276a60b..3168b1a 100644
--- a/glib/Makefile.am
+++ b/glib/Makefile.am
@@ -131,6 +131,7 @@ libglib_2_0_la_SOURCES = 	\
 	gbytes.c		\
 	gbytes.h		\
 	gcharset.c		\
+	gcharsetprivate.h	\
 	gchecksum.c		\
 	gconvert.c		\
 	gdataset.c		\
diff --git a/glib/gcharset.c b/glib/gcharset.c
index 4f52ab4..cb08027 100644
--- a/glib/gcharset.c
+++ b/glib/gcharset.c
@@ -20,7 +20,7 @@
 
 #include "config.h"
 
-#include "gcharset.h"
+#include "gcharsetprivate.h"
 
 #include "garray.h"
 #include "genviron.h"
diff --git a/glib/gcharsetprivate.h b/glib/gcharsetprivate.h
new file mode 100644
index 0000000..17a867f
--- /dev/null
+++ b/glib/gcharsetprivate.h
@@ -0,0 +1,33 @@
+/* gunicodeprivate.h
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * 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 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __G_CHARSET_PRIVATE_H__
+#define __G_CHARSET_PRIVATE_H__
+
+#include "gcharset.h"
+
+G_BEGIN_DECLS
+
+G_GNUC_INTERNAL const char ** _g_charset_get_aliases (const char *canonical_name);
+;
+
+G_END_DECLS
+
+#endif
diff --git a/glib/gconvert.c b/glib/gconvert.c
index ae25a32..368bef5 100644
--- a/glib/gconvert.c
+++ b/glib/gconvert.c
@@ -43,7 +43,7 @@
 
 #include "gconvert.h"
 
-#include "gcharset.h"
+#include "gcharsetprivate.h"
 #include "gslist.h"
 #include "gstrfuncs.h"
 #include "gtestutils.h"
diff --git a/glib/ggettext.c b/glib/ggettext.c
index ff1bb6b..f8d815e 100644
--- a/glib/ggettext.c
+++ b/glib/ggettext.c
@@ -27,6 +27,7 @@
 #include "config.h"
 
 #include "ggettext.h"
+#include "glibintl.h"
 
 #include "galloca.h"
 #include "gthread.h"
diff --git a/glib/gslice.h b/glib/gslice.h
index 3efd645..7e0c5b1 100644
--- a/glib/gslice.h
+++ b/glib/gslice.h
@@ -85,6 +85,10 @@ gint64   g_slice_get_config	   (GSliceConfig ckey);
 GLIB_DEPRECATED_IN_2_34
 gint64*  g_slice_get_config_state  (GSliceConfig ckey, gint64 address, guint *n_values);
 
+#ifdef G_ENABLE_DEBUG
+void     g_slice_debug_tree_statistics (void);
+#endif
+
 G_END_DECLS
 
 #endif /* __G_SLICE_H__ */
diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c
index f42e32c..68c633c 100644
--- a/glib/gthread-posix.c
+++ b/glib/gthread-posix.c
@@ -90,10 +90,12 @@ g_mutex_impl_new (void)
     g_thread_abort (errno, "malloc");
 
 #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
-  pthread_mutexattr_t attr;
-  pthread_mutexattr_init (&attr);
-  pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
-  pattr = &attr;
+  {
+    pthread_mutexattr_t attr;
+    pthread_mutexattr_init (&attr);
+    pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
+    pattr = &attr;
+  }
 #endif
 
   if G_UNLIKELY ((status = pthread_mutex_init (mutex, pattr)) != 0)
diff --git a/glib/gutils.c b/glib/gutils.c
index a34923d..747e5b2 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -60,6 +60,7 @@
 #include "gutils.h"
 
 #include "glib-init.h"
+#include "glib-private.h"
 #include "genviron.h"
 #include "gfileutils.h"
 #include "ggettext.h"
@@ -2416,7 +2417,7 @@ g_get_tmp_dir (void)
  * equivalent __libc_enable_secure is available).  See:
  * http://osdir.com/ml/linux.lfs.hardened/2007-04/msg00032.html
  */ 
-gboolean
+G_GNUC_INTERNAL gboolean
 g_check_setuid (void)
 {
   /* TODO: get __libc_enable_secure exported from glibc.
diff --git a/glib/tests/1bit-mutex.c b/glib/tests/1bit-mutex.c
index 8811cd3..881f1a6 100644
--- a/glib/tests/1bit-mutex.c
+++ b/glib/tests/1bit-mutex.c
@@ -21,6 +21,10 @@
 #include <glib.h>
 
 #if TEST_EMULATED_FUTEX
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+
   /* this is defined for the 1bit-mutex-emufutex test.
    *
    * we want to test the emulated futex even if futex(2) is available.
@@ -46,6 +50,8 @@
   #define G_BIT_LOCK_FORCE_FUTEX_EMULATION
 
   #include <glib/gbitlock.c>
+
+#pragma GCC diagnostic pop
 #endif
 
 volatile GThread *owners[LOCKS];
diff --git a/glib/tests/gdatetime.c b/glib/tests/gdatetime.c
index 5d28ed9..801758d 100644
--- a/glib/tests/gdatetime.c
+++ b/glib/tests/gdatetime.c
@@ -1185,12 +1185,13 @@ test_z (void)
 {
   GTimeZone *tz;
   GDateTime *dt;
+  gchar *p;
 
   g_test_bug ("642935");
 
   tz = g_time_zone_new ("-08:00");
   dt = g_date_time_new (tz, 0, 0, 0, 0, 0, 0);
-  gchar *p = g_date_time_format (dt, "%z");
+  p = g_date_time_format (dt, "%z");
   g_assert_cmpstr (p, ==, "-0800");
   g_date_time_unref (dt);
   g_time_zone_unref (tz);
diff --git a/gobject/tests/Makefile.am b/gobject/tests/Makefile.am
index 3100c2f..212cbda 100644
--- a/gobject/tests/Makefile.am
+++ b/gobject/tests/Makefile.am
@@ -34,7 +34,7 @@ marshalers.h: Makefile.am marshalers.list
 	$(AM_V_GEN) $(glib_genmarshal) --prefix=test $(srcdir)/marshalers.list --header --valist-marshallers > marshalers.h
 
 marshalers.c: Makefile.am marshalers.list
-	$(AM_V_GEN) $(glib_genmarshal) --prefix=test $(srcdir)/marshalers.list --body --valist-marshallers > marshalers.c
+	$(AM_V_GEN) (echo "#include \"marshalers.h\""; $(glib_genmarshal) --prefix=test $(srcdir)/marshalers.list --body --valist-marshallers) > $  tmp && mv $  tmp $@
 
 BUILT_SOURCES = marshalers.h marshalers.c
 CLEANFILES = marshalers.h marshalers.c
diff --git a/gobject/tests/param.c b/gobject/tests/param.c
index 5b14fcf..0c9edab 100644
--- a/gobject/tests/param.c
+++ b/gobject/tests/param.c
@@ -457,6 +457,7 @@ static void test_object_c_init (TestObjectC *c) { }
  * That gives 21 (7 * 3) properties that will be installed.
  */
 typedef GTypeInterface TestInterfaceInterface;
+static GType test_interface_get_type (void);
 //typedef struct _TestInterface TestInterface;
 G_DEFINE_INTERFACE (TestInterface, test_interface, G_TYPE_OBJECT)
 static void
diff --git a/gobject/tests/threadtests.c b/gobject/tests/threadtests.c
index eae7ec0..fd33222 100644
--- a/gobject/tests/threadtests.c
+++ b/gobject/tests/threadtests.c
@@ -41,7 +41,7 @@ call_counter_init (gpointer tclass)
     }
 }
 
-static void interface_per_class_init () { call_counter_init (NULL); }
+static void interface_per_class_init (void) { call_counter_init (NULL); }
 
 /* define 3 test interfaces */
 typedef GTypeInterface MyFace0Interface;
diff --git a/m4macros/attributes.m4 b/m4macros/attributes.m4
new file mode 100644
index 0000000..f0bcf24
--- /dev/null
+++ b/m4macros/attributes.m4
@@ -0,0 +1,288 @@
+dnl Macros to check the presence of generic (non-typed) symbols.
+dnl Copyright (c) 2006-2008 Diego Pettenà <flameeyes gmail com>
+dnl Copyright (c) 2006-2008 xine project
+dnl Copyright (c) 2012 Lucas De Marchi <lucas de marchi gmail com>
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2, or (at your option)
+dnl any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+dnl 02110-1301, USA.
+dnl
+dnl As a special exception, the copyright owners of the
+dnl macro gives unlimited permission to copy, distribute and modify the
+dnl configure scripts that are the output of Autoconf when processing the
+dnl Macro. You need not follow the terms of the GNU General Public
+dnl License when using or distributing such scripts, even though portions
+dnl of the text of the Macro appear in them. The GNU General Public
+dnl License (GPL) does govern all other use of the material that
+dnl constitutes the Autoconf Macro.
+dnl
+dnl This special exception to the GPL applies to versions of the
+dnl Autoconf Macro released by this project. When you make and
+dnl distribute a modified version of the Autoconf Macro, you may extend
+dnl this special exception to the GPL to apply to your modified version as
+dnl well.
+
+dnl Check if FLAG in ENV-VAR is supported by compiler and append it
+dnl to WHERE-TO-APPEND variable
+dnl CC_CHECK_FLAG_APPEND([WHERE-TO-APPEND], [ENV-VAR], [FLAG])
+
+AC_DEFUN([CC_CHECK_FLAG_APPEND], [
+  AC_CACHE_CHECK([if $CC supports flag $3 in envvar $2],
+                 AS_TR_SH([cc_cv_$2_$3]),
+		 [eval "AS_TR_SH([cc_save_$2])='${$2}'"
+		  eval "AS_TR_SH([$2])='-Werror $3'"
+		  AC_COMPILE_IFELSE([AC_LANG_SOURCE([int a = 0; int main(void) { return a; } ])],
+                                    [eval "AS_TR_SH([cc_cv_$2_$3])='yes'"],
+                                    [eval "AS_TR_SH([cc_cv_$2_$3])='no'"])
+		  eval "AS_TR_SH([$2])='$cc_save_$2'"])
+
+  AS_IF([eval test x$]AS_TR_SH([cc_cv_$2_$3])[ = xyes],
+        [eval "$1='${$1} $3'"])
+])
+
+dnl CC_CHECK_FLAGS_APPEND([WHERE-TO-APPEND], [ENV-VAR], [FLAG1 FLAG2])
+AC_DEFUN([CC_CHECK_FLAGS_APPEND], [
+  for flag in $3; do
+    CC_CHECK_FLAG_APPEND($1, $2, $flag)
+  done
+])
+
+dnl Check if the flag is supported by linker (cacheable)
+dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+
+AC_DEFUN([CC_CHECK_LDFLAGS], [
+  AC_CACHE_CHECK([if $CC supports $1 flag],
+    AS_TR_SH([cc_cv_ldflags_$1]),
+    [ac_save_LDFLAGS="$LDFLAGS"
+     LDFLAGS="$LDFLAGS $1"
+     AC_LINK_IFELSE([int main() { return 1; }],
+       [eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"],
+       [eval "AS_TR_SH([cc_cv_ldflags_$1])="])
+     LDFLAGS="$ac_save_LDFLAGS"
+    ])
+
+  AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes],
+    [$2], [$3])
+])
+
+dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for
+dnl the current linker to avoid undefined references in a shared object.
+AC_DEFUN([CC_NOUNDEFINED], [
+  dnl We check $host for which systems to enable this for.
+  AC_REQUIRE([AC_CANONICAL_HOST])
+
+  case $host in
+     dnl FreeBSD (et al.) does not complete linking for shared objects when pthreads
+     dnl are requested, as different implementations are present; to avoid problems
+     dnl use -Wl,-z,defs only for those platform not behaving this way.
+     *-freebsd* | *-openbsd*) ;;
+     *)
+        dnl First of all check for the --no-undefined variant of GNU ld. This allows
+        dnl for a much more readable commandline, so that people can understand what
+        dnl it does without going to look for what the heck -z defs does.
+        for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do
+          CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"])
+	  break
+        done
+	;;
+  esac
+
+  AC_SUBST([LDFLAGS_NOUNDEFINED])
+])
+
+dnl Check for a -Werror flag or equivalent. -Werror is the GCC
+dnl and ICC flag that tells the compiler to treat all the warnings
+dnl as fatal. We usually need this option to make sure that some
+dnl constructs (like attributes) are not simply ignored.
+dnl
+dnl Other compilers don't support -Werror per se, but they support
+dnl an equivalent flag:
+dnl  - Sun Studio compiler supports -errwarn=%all
+AC_DEFUN([CC_CHECK_WERROR], [
+  AC_CACHE_CHECK(
+    [for $CC way to treat warnings as errors],
+    [cc_cv_werror],
+    [CC_CHECK_CFLAGS_SILENT([-Werror], [cc_cv_werror=-Werror],
+      [CC_CHECK_CFLAGS_SILENT([-errwarn=%all], [cc_cv_werror=-errwarn=%all])])
+    ])
+])
+
+AC_DEFUN([CC_CHECK_ATTRIBUTE], [
+  AC_REQUIRE([CC_CHECK_WERROR])
+  AC_CACHE_CHECK([if $CC supports __attribute__(( ifelse([$2], , [$1], [$2]) ))],
+    AS_TR_SH([cc_cv_attribute_$1]),
+    [ac_save_CFLAGS="$CFLAGS"
+     CFLAGS="$CFLAGS $cc_cv_werror"
+     AC_COMPILE_IFELSE([AC_LANG_SOURCE([$3])],
+       [eval "AS_TR_SH([cc_cv_attribute_$1])='yes'"],
+       [eval "AS_TR_SH([cc_cv_attribute_$1])='no'"])
+     CFLAGS="$ac_save_CFLAGS"
+    ])
+
+  AS_IF([eval test x$]AS_TR_SH([cc_cv_attribute_$1])[ = xyes],
+    [AC_DEFINE(
+       AS_TR_CPP([SUPPORT_ATTRIBUTE_$1]), 1,
+         [Define this if the compiler supports __attribute__(( ifelse([$2], , [$1], [$2]) ))]
+         )
+     $4],
+    [$5])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [
+  CC_CHECK_ATTRIBUTE(
+    [constructor],,
+    [void __attribute__((constructor)) ctor() { int a; }],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_FORMAT], [
+  CC_CHECK_ATTRIBUTE(
+    [format], [format(printf, n, n)],
+    [void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { fmt = (void *)0; }],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [
+  CC_CHECK_ATTRIBUTE(
+    [format_arg], [format_arg(printf)],
+    [char *__attribute__((format_arg(1))) gettextlike(const char *fmt) { fmt = (void *)0; }],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [
+  CC_CHECK_ATTRIBUTE(
+    [visibility_$1], [visibility("$1")],
+    [void __attribute__((visibility("$1"))) $1_function() { }],
+    [$2], [$3])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_NONNULL], [
+  CC_CHECK_ATTRIBUTE(
+    [nonnull], [nonnull()],
+    [void __attribute__((nonnull())) some_function(void *foo, void *bar) { foo = (void*)0; bar = (void*)0; }],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_UNUSED], [
+  CC_CHECK_ATTRIBUTE(
+    [unused], ,
+    [void some_function(void *foo, __attribute__((unused)) void *bar);],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [
+  CC_CHECK_ATTRIBUTE(
+    [sentinel], ,
+    [void some_function(void *foo, ...) __attribute__((sentinel));],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_DEPRECATED], [
+  CC_CHECK_ATTRIBUTE(
+    [deprecated], ,
+    [void some_function(void *foo, ...) __attribute__((deprecated));],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_ALIAS], [
+  CC_CHECK_ATTRIBUTE(
+    [alias], [weak, alias],
+    [void other_function(void *foo) { }
+     void some_function(void *foo) __attribute__((weak, alias("other_function")));],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_MALLOC], [
+  CC_CHECK_ATTRIBUTE(
+    [malloc], ,
+    [void * __attribute__((malloc)) my_alloc(int n);],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_PACKED], [
+  CC_CHECK_ATTRIBUTE(
+    [packed], ,
+    [struct astructure { char a; int b; long c; void *d; } __attribute__((packed));],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_CONST], [
+  CC_CHECK_ATTRIBUTE(
+    [const], ,
+    [int __attribute__((const)) twopow(int n) { return 1 << n; } ],
+    [$1], [$2])
+])
+
+AC_DEFUN([CC_FLAG_VISIBILITY], [
+  AC_REQUIRE([CC_CHECK_WERROR])
+  AC_CACHE_CHECK([if $CC supports -fvisibility=hidden],
+    [cc_cv_flag_visibility],
+    [cc_flag_visibility_save_CFLAGS="$CFLAGS"
+     CFLAGS="$CFLAGS $cc_cv_werror"
+     CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden],
+	cc_cv_flag_visibility='yes',
+	cc_cv_flag_visibility='no')
+     CFLAGS="$cc_flag_visibility_save_CFLAGS"])
+
+  AS_IF([test "x$cc_cv_flag_visibility" = "xyes"],
+    [AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1,
+       [Define this if the compiler supports the -fvisibility flag])
+     $1],
+    [$2])
+])
+
+AC_DEFUN([CC_FUNC_EXPECT], [
+  AC_REQUIRE([CC_CHECK_WERROR])
+  AC_CACHE_CHECK([if compiler has __builtin_expect function],
+    [cc_cv_func_expect],
+    [ac_save_CFLAGS="$CFLAGS"
+     CFLAGS="$CFLAGS $cc_cv_werror"
+     AC_COMPILE_IFELSE([AC_LANG_SOURCE(
+       [int some_function() {
+        int a = 3;
+        return (int)__builtin_expect(a, 3);
+	}])],
+       [cc_cv_func_expect=yes],
+       [cc_cv_func_expect=no])
+     CFLAGS="$ac_save_CFLAGS"
+    ])
+
+  AS_IF([test "x$cc_cv_func_expect" = "xyes"],
+    [AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1,
+     [Define this if the compiler supports __builtin_expect() function])
+     $1],
+    [$2])
+])
+
+AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [
+  AC_REQUIRE([CC_CHECK_WERROR])
+  AC_CACHE_CHECK([highest __attribute__ ((aligned ())) supported],
+    [cc_cv_attribute_aligned],
+    [ac_save_CFLAGS="$CFLAGS"
+     CFLAGS="$CFLAGS $cc_cv_werror"
+     for cc_attribute_align_try in 64 32 16 8 4 2; do
+        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+          int main() {
+            static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0;
+            return c;
+          }])], [cc_cv_attribute_aligned=$cc_attribute_align_try; break])
+     done
+     CFLAGS="$ac_save_CFLAGS"
+  ])
+
+  if test "x$cc_cv_attribute_aligned" != "x"; then
+     AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX], [$cc_cv_attribute_aligned],
+       [Define the highest alignment supported])
+  fi
+])
diff --git a/tests/gobject/Makefile.am b/tests/gobject/Makefile.am
index fcb4e23..63f2bcf 100644
--- a/tests/gobject/Makefile.am
+++ b/tests/gobject/Makefile.am
@@ -40,8 +40,8 @@ stamp-testmarshal.h: @REBUILD@ testmarshal.list $(glib_genmarshal)
 	&& (cmp -s xgen-gmh testmarshal.h 2>/dev/null || cp xgen-gmh testmarshal.h) \
 	&& rm -f xgen-gmh xgen-gmh~ \
 	&& echo timestamp > $@
-testmarshal.c: @REBUILD@ testmarshal.list $(glib_genmarshal)
-	$(AM_V_GEN) $(glib_genmarshal) --prefix=test_marshal $(srcdir)/testmarshal.list --body >> xgen-gmc \
+testmarshal.c: @REBUILD@ testmarshal.h testmarshal.list $(glib_genmarshal)
+	$(AM_V_GEN) (echo "#include \"testmarshal.h\""; $(glib_genmarshal) --prefix=test_marshal $(srcdir)/testmarshal.list --body) >> xgen-gmc \
 	&& cp xgen-gmc testmarshal.c \
 	&& rm -f xgen-gmc xgen-gmc~
 
diff --git a/tests/libmoduletestplugin_a.c b/tests/libmoduletestplugin_a.c
index 150d50d..69fdd0f 100644
--- a/tests/libmoduletestplugin_a.c
+++ b/tests/libmoduletestplugin_a.c
@@ -30,6 +30,12 @@
 #include	<gmodule.h>
 #include	<stdlib.h>
 
+void gplugin_a_func (void);
+void gplugin_clash_func (void);
+void g_clash_func (void);
+void gplugin_say_boo_func (void);
+void gplugin_a_module_func (GModule *module);
+
 G_MODULE_EXPORT gchar* gplugin_a_state;
 
 G_MODULE_EXPORT void
diff --git a/tests/libmoduletestplugin_b.c b/tests/libmoduletestplugin_b.c
index 26e065d..26cc33f 100644
--- a/tests/libmoduletestplugin_b.c
+++ b/tests/libmoduletestplugin_b.c
@@ -31,6 +31,14 @@
 
 G_MODULE_EXPORT gchar* gplugin_b_state;
 
+const gchar* g_module_check_init (GModule *module);
+void   g_module_unload (GModule *module);
+
+void gplugin_b_func (void);
+void gplugin_clash_func (void);
+void g_clash_func (void);
+void gplugin_say_boo_func (void);
+
 G_MODULE_EXPORT const gchar*
 g_module_check_init (GModule *module)
 {
diff --git a/tests/refcount/closures.c b/tests/refcount/closures.c
index de48192..cc29354 100644
--- a/tests/refcount/closures.c
+++ b/tests/refcount/closures.c
@@ -43,6 +43,7 @@ typedef struct {
 #define MY_IS_TEST_CLASS(tclass)   (G_TYPE_CHECK_CLASS_TYPE ((tclass), G_TYPE_TEST))
 #define MY_TEST_GET_CLASS(test)    (G_TYPE_INSTANCE_GET_CLASS ((test), G_TYPE_TEST, GTestClass))
 
+static GType my_test_get_type (void);
 G_DEFINE_TYPE (GTest, my_test, G_TYPE_OBJECT);
 
 /* --- variables --- */
diff --git a/tests/refcount/properties3.c b/tests/refcount/properties3.c
index a5e9257..5821188 100644
--- a/tests/refcount/properties3.c
+++ b/tests/refcount/properties3.c
@@ -31,6 +31,7 @@ struct _GTestClass
   GObjectClass parent_class;
 };
 
+static GType my_test_get_type (void);
 G_DEFINE_TYPE (GTest, my_test, G_TYPE_OBJECT);
 
 static volatile gboolean stopping;
diff --git a/tests/refcount/properties4.c b/tests/refcount/properties4.c
index d02a5c6..2512160 100644
--- a/tests/refcount/properties4.c
+++ b/tests/refcount/properties4.c
@@ -29,6 +29,7 @@ struct _MyBadgerClass
   GObjectClass parent_class;
 };
 
+static GType my_badger_get_type (void);
 G_DEFINE_TYPE (MyBadger, my_badger, G_TYPE_OBJECT);
 
 static void my_badger_dispose (GObject * object);
diff --git a/tests/testgdate.c b/tests/testgdate.c
index 85d22dc..f5fc435 100644
--- a/tests/testgdate.c
+++ b/tests/testgdate.c
@@ -29,7 +29,8 @@ else \
   if ((passed+notpassed) % 10000 == 0) g_print ("."); fflush (stdout); \
 } G_STMT_END
 
-void g_date_debug_print(GDate* d)
+static void
+g_date_debug_print (GDate* d)
 {
   if (!d) g_print("NULL!\n");
   else 
diff --git a/tests/testgdateparser.c b/tests/testgdateparser.c
index f0e284a..ab94bcb 100644
--- a/tests/testgdateparser.c
+++ b/tests/testgdateparser.c
@@ -11,7 +11,8 @@
 #include <string.h>
 #include <locale.h>
 
-void g_date_debug_print(GDate* d)
+static void
+g_date_debug_print (GDate* d)
 {
   if (!d) g_print("NULL!\n");
   else 
diff --git a/tests/unicode-collate.c b/tests/unicode-collate.c
index 785f169..b276a2f 100644
--- a/tests/unicode-collate.c
+++ b/tests/unicode-collate.c
@@ -13,7 +13,7 @@ typedef struct {
 } Line;
   
 
-int 
+static int 
 compare_collate (const void *a, const void *b)
 {
   const Line *line_a = a;
@@ -22,7 +22,7 @@ compare_collate (const void *a, const void *b)
   return g_utf8_collate (line_a->str, line_b->str);
 }
 
-int 
+static int 
 compare_key (const void *a, const void *b)
 {
   const Line *line_a = a;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]