shared/gsystem-local-alloc: rename unused gs_* cleanup macros

These cleanup macros are unused by NetworkManager code. Note that
since "shared/nm-utils" is used by applet and VPN plugins, theoretically,
they could be used there. I didn't check that, but breaking API of
"shared/nm-utils" is fine (as long as we catch it with a compilation
error).

Historically, we use libgsystem's gsystem-local-alloc header and their
"gs_*" macros. However, they are not really our style and don't have
a nm-prefix (like the rest of our code). We keep the gs_ names, because
they are wildly used and because we wanted to keep gsystem-local-alloc
in sync with upstream (which is no longer the case).

Our own cleanup macros are always called "nm_auto_*". So, at least
for the unused "gs_*" macros, rename them to "nm_auto_*".

Don't drop them, despite they being unused. The reason is, that we should
make use of cleanup functions more eagerly. Dropping them now -- because
they are momentarily unused -- hampers using them in the future. We
often don't use the cleanup macros at places where I think we should,
so by dropping them, we hamper future use.
This commit is contained in:
Thomas Haller 2018-07-13 16:42:52 +02:00
parent 5513af2e14
commit 904e8b8ca0
2 changed files with 12 additions and 37 deletions

View file

@ -87,24 +87,6 @@ GS_DEFINE_CLEANUP_FUNCTION_VOID0 (GObject *, gs_local_obj_unref, g_object_unref)
#define gs_unref_variant __attribute__ ((cleanup(gs_local_variant_unref)))
GS_DEFINE_CLEANUP_FUNCTION0 (GVariant *, gs_local_variant_unref, g_variant_unref)
/**
* gs_free_variant_iter:
*
* Call g_variant_iter_free() on a variable location when it goes out of
* scope.
*/
#define gs_free_variant_iter __attribute__ ((cleanup(gs_local_variant_iter_free)))
GS_DEFINE_CLEANUP_FUNCTION0 (GVariantIter *, gs_local_variant_iter_free, g_variant_iter_free)
/**
* gs_free_variant_builder:
*
* Call g_variant_builder_unref() on a variable location when it goes out of
* scope.
*/
#define gs_unref_variant_builder __attribute__ ((cleanup(gs_local_variant_builder_unref)))
GS_DEFINE_CLEANUP_FUNCTION0 (GVariantBuilder *, gs_local_variant_builder_unref, g_variant_builder_unref)
/**
* gs_unref_array:
*
@ -137,15 +119,6 @@ GS_DEFINE_CLEANUP_FUNCTION0 (GPtrArray *, gs_local_ptrarray_unref, g_ptr_array_u
#define gs_unref_hashtable __attribute__ ((cleanup(gs_local_hashtable_unref)))
GS_DEFINE_CLEANUP_FUNCTION0 (GHashTable *, gs_local_hashtable_unref, g_hash_table_unref)
/**
* gs_free_list:
*
* Call g_list_free() on a variable location when it goes out
* of scope.
*/
#define gs_free_list __attribute__ ((cleanup(gs_local_free_list)))
GS_DEFINE_CLEANUP_FUNCTION (GList *, gs_local_free_list, g_list_free)
/**
* gs_free_slist:
*
@ -155,16 +128,6 @@ GS_DEFINE_CLEANUP_FUNCTION (GList *, gs_local_free_list, g_list_free)
#define gs_free_slist __attribute__ ((cleanup(gs_local_free_slist)))
GS_DEFINE_CLEANUP_FUNCTION (GSList *, gs_local_free_slist, g_slist_free)
/**
* gs_free_checksum:
*
* Call g_checksum_free() on a variable location when it goes out
* of scope. Note that unlike g_checksum_free(), the variable may
* be %NULL.
*/
#define gs_free_checksum __attribute__ ((cleanup(gs_local_checksum_free)))
GS_DEFINE_CLEANUP_FUNCTION0 (GChecksum *, gs_local_checksum_free, g_checksum_free)
/**
* gs_unref_bytes:
*

View file

@ -84,6 +84,18 @@ static inline int nm_close (int fd);
GS_DEFINE_CLEANUP_FUNCTION_VOID (void *, _nm_auto_free_impl, free)
#define nm_auto_free nm_auto(_nm_auto_free_impl)
GS_DEFINE_CLEANUP_FUNCTION0 (GVariantIter *, _nm_auto_free_variant_iter, g_variant_iter_free)
#define nm_auto_free_variant_iter __attribute__ ((cleanup(_nm_auto_free_variant_iter)))
GS_DEFINE_CLEANUP_FUNCTION0 (GVariantBuilder *, _nm_auto_unref_variant_builder, g_variant_builder_unref)
#define nm_auto_unref_variant_builder __attribute__ ((cleanup(_nm_auto_unref_variant_builder)))
GS_DEFINE_CLEANUP_FUNCTION (GList *, _nm_auto_free_list, g_list_free)
#define nm_auto_free_list __attribute__ ((cleanup(_nm_auto_free_list)))
GS_DEFINE_CLEANUP_FUNCTION0 (GChecksum *, _nm_auto_checksum_free, g_checksum_free)
#define nm_auto_free_checksum __attribute__ ((cleanup(_nm_auto_checksum_free)))
static inline void
nm_free_secret (char *secret)
{