summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2018-05-25 13:13:33 +0000
committerPhilip Withnall <philip@tecnocode.co.uk>2018-05-25 13:13:33 +0000
commit89c6d64a970e44e0cddb56c9841b762c897442c6 (patch)
tree7fa2f25019f530be53b971dff8733b966c76f75e
parentd981b997ca1c65e1e41bf32a4570abf2ba2ce774 (diff)
parentc7d11d3418a7eafb2946a28946b902147d8230ed (diff)
downloadglib-89c6d64a970e44e0cddb56c9841b762c897442c6.tar.gz
Merge branch 'master' into 'master'
macros: Double-cast func for g_autolist to avoid warning Closes #1382 and #1390 See merge request GNOME/glib!8
-rw-r--r--glib/gmacros.h6
-rw-r--r--glib/tests/autoptr.c6
2 files changed, 9 insertions, 3 deletions
diff --git a/glib/gmacros.h b/glib/gmacros.h
index 55fb81e5b..0e180bb09 100644
--- a/glib/gmacros.h
+++ b/glib/gmacros.h
@@ -482,9 +482,9 @@
typedef GList *_GLIB_AUTOPTR_LIST_TYPENAME(TypeName); \
typedef GSList *_GLIB_AUTOPTR_SLIST_TYPENAME(TypeName); \
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
- static inline void _GLIB_AUTOPTR_FUNC_NAME(TypeName) (TypeName **_ptr) { if (*_ptr) (func) (*_ptr); } \
- static inline void _GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName) (GList **_l) { g_list_free_full (*_l, (GDestroyNotify) func); } \
- static inline void _GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName) (GSList **_l) { g_slist_free_full (*_l, (GDestroyNotify) func); } \
+ static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_FUNC_NAME(TypeName) (TypeName **_ptr) { if (*_ptr) (func) (*_ptr); } \
+ static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName) (GList **_l) { g_list_free_full (*_l, (GDestroyNotify) (void(*)(void)) func); } \
+ static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName) (GSList **_l) { g_slist_free_full (*_l, (GDestroyNotify) (void(*)(void)) func); } \
G_GNUC_END_IGNORE_DEPRECATIONS
#define G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func) \
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
diff --git a/glib/tests/autoptr.c b/glib/tests/autoptr.c
index 408f14b6c..c8c130d5c 100644
--- a/glib/tests/autoptr.c
+++ b/glib/tests/autoptr.c
@@ -1,6 +1,12 @@
#include <glib.h>
#include <string.h>
+typedef struct _HNVC HasNonVoidCleanup;
+HasNonVoidCleanup * non_void_cleanup (HasNonVoidCleanup *);
+
+/* Should not cause any warnings with -Wextra */
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(HasNonVoidCleanup, non_void_cleanup)
+
static void
test_autofree (void)
{