summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-07-18 10:27:20 +0200
committerThomas Haller <thaller@redhat.com>2018-07-18 10:27:39 +0200
commit196d7c8ca5ab758661b652a86980575eb8b9ce62 (patch)
tree86dad6c1f76802ac46f922664820d1e3966a9c02
parentd0b3702b37701b2835eb6922258ceee3bd13e870 (diff)
downloadNetworkManager-th/merge-gsystem-local-alloc.tar.gz
shared: use nm_auto() macro to define other nm_auto_* macrosth/merge-gsystem-local-alloc
-rw-r--r--shared/nm-utils/nm-macros-internal.h34
1 files changed, 17 insertions, 17 deletions
diff --git a/shared/nm-utils/nm-macros-internal.h b/shared/nm-utils/nm-macros-internal.h
index 72b4cd44af..6d5e25b28c 100644
--- a/shared/nm-utils/nm-macros-internal.h
+++ b/shared/nm-utils/nm-macros-internal.h
@@ -40,6 +40,8 @@
#define _nm_align(s) __attribute__ ((aligned (s)))
#define _nm_alignof(type) __alignof (type)
#define _nm_alignas(type) _nm_align (_nm_alignof (type))
+#define nm_auto(fcn) __attribute__ ((cleanup(fcn)))
+
#if __GNUC__ >= 7
#define _nm_fallthrough __attribute__ ((fallthrough))
@@ -102,7 +104,7 @@ static inline void name (Type *v) \
*
* Call g_free() on a variable location when it goes out of scope.
*/
-#define gs_free __attribute__ ((cleanup(gs_local_free)))
+#define gs_free nm_auto(gs_local_free)
NM_AUTO_DEFINE_FCN_VOID (void *, gs_local_free, g_free)
/**
@@ -112,7 +114,7 @@ NM_AUTO_DEFINE_FCN_VOID (void *, gs_local_free, g_free)
* scope. Note that unlike g_object_unref(), the variable may be
* %NULL.
*/
-#define gs_unref_object __attribute__ ((cleanup(gs_local_obj_unref)))
+#define gs_unref_object nm_auto(gs_local_obj_unref)
NM_AUTO_DEFINE_FCN_VOID0 (GObject *, gs_local_obj_unref, g_object_unref)
/**
@@ -122,7 +124,7 @@ NM_AUTO_DEFINE_FCN_VOID0 (GObject *, gs_local_obj_unref, g_object_unref)
* scope. Note that unlike g_variant_unref(), the variable may be
* %NULL.
*/
-#define gs_unref_variant __attribute__ ((cleanup(gs_local_variant_unref)))
+#define gs_unref_variant nm_auto(gs_local_variant_unref)
NM_AUTO_DEFINE_FCN0 (GVariant *, gs_local_variant_unref, g_variant_unref)
/**
@@ -133,7 +135,7 @@ NM_AUTO_DEFINE_FCN0 (GVariant *, gs_local_variant_unref, g_variant_unref)
* %NULL.
*/
-#define gs_unref_array __attribute__ ((cleanup(gs_local_array_unref)))
+#define gs_unref_array nm_auto(gs_local_array_unref)
NM_AUTO_DEFINE_FCN0 (GArray *, gs_local_array_unref, g_array_unref)
/**
@@ -144,7 +146,7 @@ NM_AUTO_DEFINE_FCN0 (GArray *, gs_local_array_unref, g_array_unref)
* %NULL.
*/
-#define gs_unref_ptrarray __attribute__ ((cleanup(gs_local_ptrarray_unref)))
+#define gs_unref_ptrarray nm_auto(gs_local_ptrarray_unref)
NM_AUTO_DEFINE_FCN0 (GPtrArray *, gs_local_ptrarray_unref, g_ptr_array_unref)
/**
@@ -154,7 +156,7 @@ NM_AUTO_DEFINE_FCN0 (GPtrArray *, gs_local_ptrarray_unref, g_ptr_array_unref)
* of scope. Note that unlike g_hash_table_unref(), the variable may
* be %NULL.
*/
-#define gs_unref_hashtable __attribute__ ((cleanup(gs_local_hashtable_unref)))
+#define gs_unref_hashtable nm_auto(gs_local_hashtable_unref)
NM_AUTO_DEFINE_FCN0 (GHashTable *, gs_local_hashtable_unref, g_hash_table_unref)
/**
@@ -163,7 +165,7 @@ NM_AUTO_DEFINE_FCN0 (GHashTable *, gs_local_hashtable_unref, g_hash_table_unref)
* Call g_slist_free() on a variable location when it goes out
* of scope.
*/
-#define gs_free_slist __attribute__ ((cleanup(gs_local_free_slist)))
+#define gs_free_slist nm_auto(gs_local_free_slist)
NM_AUTO_DEFINE_FCN (GSList *, gs_local_free_slist, g_slist_free)
/**
@@ -173,7 +175,7 @@ NM_AUTO_DEFINE_FCN (GSList *, gs_local_free_slist, g_slist_free)
* of scope. Note that unlike g_bytes_unref(), the variable may
* be %NULL.
*/
-#define gs_unref_bytes __attribute__ ((cleanup(gs_local_bytes_unref)))
+#define gs_unref_bytes nm_auto(gs_local_bytes_unref)
NM_AUTO_DEFINE_FCN0 (GBytes *, gs_local_bytes_unref, g_bytes_unref)
/**
@@ -181,7 +183,7 @@ NM_AUTO_DEFINE_FCN0 (GBytes *, gs_local_bytes_unref, g_bytes_unref)
*
* Call g_strfreev() on a variable location when it goes out of scope.
*/
-#define gs_strfreev __attribute__ ((cleanup(gs_local_strfreev)))
+#define gs_strfreev nm_auto(gs_local_strfreev)
NM_AUTO_DEFINE_FCN (char **, gs_local_strfreev, g_strfreev)
/**
@@ -189,7 +191,7 @@ NM_AUTO_DEFINE_FCN (char **, gs_local_strfreev, g_strfreev)
*
* Call g_error_free() on a variable location when it goes out of scope.
*/
-#define gs_free_error __attribute__ ((cleanup(gs_local_free_error)))
+#define gs_free_error nm_auto(gs_local_free_error)
NM_AUTO_DEFINE_FCN0 (GError *, gs_local_free_error, g_error_free)
/**
@@ -197,7 +199,7 @@ NM_AUTO_DEFINE_FCN0 (GError *, gs_local_free_error, g_error_free)
*
* Call g_key_file_unref() on a variable location when it goes out of scope.
*/
-#define gs_unref_keyfile __attribute__ ((cleanup(gs_local_keyfile_unref)))
+#define gs_unref_keyfile nm_auto(gs_local_keyfile_unref)
NM_AUTO_DEFINE_FCN0 (GKeyFile *, gs_local_keyfile_unref, g_key_file_unref)
/*****************************************************************************/
@@ -213,8 +215,6 @@ NM_AUTO_DEFINE_FCN0 (GKeyFile *, gs_local_keyfile_unref, g_key_file_unref)
static inline int nm_close (int fd);
static inline void nm_free_secret (char *secret);
-#define nm_auto(fcn) __attribute__ ((cleanup(fcn)))
-
/**
* nm_auto_free:
*
@@ -233,16 +233,16 @@ NM_AUTO_DEFINE_FCN_VOID (void *, _nm_auto_free_impl, free)
#define nm_auto_free nm_auto(_nm_auto_free_impl)
NM_AUTO_DEFINE_FCN0 (GVariantIter *, _nm_auto_free_variant_iter, g_variant_iter_free)
-#define nm_auto_free_variant_iter __attribute__ ((cleanup(_nm_auto_free_variant_iter)))
+#define nm_auto_free_variant_iter nm_auto(_nm_auto_free_variant_iter)
NM_AUTO_DEFINE_FCN0 (GVariantBuilder *, _nm_auto_unref_variant_builder, g_variant_builder_unref)
-#define nm_auto_unref_variant_builder __attribute__ ((cleanup(_nm_auto_unref_variant_builder)))
+#define nm_auto_unref_variant_builder nm_auto(_nm_auto_unref_variant_builder)
NM_AUTO_DEFINE_FCN (GList *, _nm_auto_free_list, g_list_free)
-#define nm_auto_free_list __attribute__ ((cleanup(_nm_auto_free_list)))
+#define nm_auto_free_list nm_auto(_nm_auto_free_list)
NM_AUTO_DEFINE_FCN0 (GChecksum *, _nm_auto_checksum_free, g_checksum_free)
-#define nm_auto_free_checksum __attribute__ ((cleanup(_nm_auto_checksum_free)))
+#define nm_auto_free_checksum nm_auto(_nm_auto_checksum_free)
NM_AUTO_DEFINE_FCN (char *, _nm_auto_free_secret, nm_free_secret)
/**