summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-10-22 16:25:32 +0200
committerAntonio Cardace <acardace@redhat.com>2020-10-22 17:38:08 +0200
commit6e44842dc69d03549e1a3bd842988308d2969fd3 (patch)
tree791ad38ce79d9fbac0eca3553c849ea1dcd4e30c
parent515df289de73575e49786855245d1374f0e1e53c (diff)
shared: introduce opaque type NMUtilsUserData for nm_utils_user_data_pack()
This makes the usage slightly more type safe.
-rw-r--r--shared/nm-glib-aux/nm-shared-utils.c8
-rw-r--r--shared/nm-glib-aux/nm-shared-utils.h6
2 files changed, 8 insertions, 6 deletions
diff --git a/shared/nm-glib-aux/nm-shared-utils.c b/shared/nm-glib-aux/nm-shared-utils.c
index b0e023817..7f766871f 100644
--- a/shared/nm-glib-aux/nm-shared-utils.c
+++ b/shared/nm-glib-aux/nm-shared-utils.c
@@ -4115,7 +4115,7 @@ nm_utils_g_slist_strlist_join(const GSList *a, const char *separator)
/*****************************************************************************/
-gpointer
+NMUtilsUserData *
_nm_utils_user_data_pack(int nargs, gconstpointer *args)
{
int i;
@@ -4127,13 +4127,13 @@ _nm_utils_user_data_pack(int nargs, gconstpointer *args)
data = g_slice_alloc(((gsize) nargs) * sizeof(gconstpointer));
for (i = 0; i < nargs; i++)
data[i] = (gpointer) args[i];
- return data;
+ return (NMUtilsUserData *) data;
}
void
-_nm_utils_user_data_unpack(gpointer user_data, int nargs, ...)
+_nm_utils_user_data_unpack(NMUtilsUserData *user_data, int nargs, ...)
{
- gpointer *data = user_data;
+ gpointer *data = (gpointer *) user_data;
va_list ap;
int i;
diff --git a/shared/nm-glib-aux/nm-shared-utils.h b/shared/nm-glib-aux/nm-shared-utils.h
index 99ae78ccb..06bf9dd04 100644
--- a/shared/nm-glib-aux/nm-shared-utils.h
+++ b/shared/nm-glib-aux/nm-shared-utils.h
@@ -1789,12 +1789,14 @@ nm_utils_process_state_is_dead(char pstate)
/*****************************************************************************/
-gpointer _nm_utils_user_data_pack(int nargs, gconstpointer *args);
+typedef struct _NMUtilsUserData NMUtilsUserData;
+
+NMUtilsUserData *_nm_utils_user_data_pack(int nargs, gconstpointer *args);
#define nm_utils_user_data_pack(...) \
_nm_utils_user_data_pack(NM_NARG(__VA_ARGS__), (gconstpointer[]){__VA_ARGS__})
-void _nm_utils_user_data_unpack(gpointer user_data, int nargs, ...);
+void _nm_utils_user_data_unpack(NMUtilsUserData *user_data, int nargs, ...);
#define nm_utils_user_data_unpack(user_data, ...) \
_nm_utils_user_data_unpack(user_data, NM_NARG(__VA_ARGS__), __VA_ARGS__)