summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--callouts/nm-dispatcher-action.c10
-rw-r--r--callouts/nm-dispatcher-utils.c24
-rw-r--r--cli/src/connections.c4
-rw-r--r--examples/C/glib/list-connections-libnm-glib.c4
-rw-r--r--libnm-glib/libnm_glib.c3
-rw-r--r--libnm-glib/nm-active-connection.c2
-rw-r--r--libnm-glib/nm-client.c3
-rw-r--r--libnm-glib/nm-device-bond.c2
-rw-r--r--libnm-glib/nm-device-bridge.c2
-rw-r--r--libnm-glib/nm-device-team.c2
-rw-r--r--libnm-glib/nm-ip4-config.c17
-rw-r--r--libnm-glib/nm-ip6-config.c21
-rw-r--r--libnm-glib/nm-object.c9
-rw-r--r--libnm-glib/nm-types.c3
-rw-r--r--libnm-util/nm-param-spec-specialized.c6
-rw-r--r--libnm-util/nm-setting-vpn.c3
-rw-r--r--libnm-util/nm-setting-wired.c4
-rw-r--r--src/devices/nm-device.c6
-rw-r--r--src/devices/wimax/nm-device-wimax.c3
-rw-r--r--src/nm-dbus-manager.c7
-rw-r--r--src/nm-manager.c3
-rw-r--r--src/settings/nm-secret-agent.c3
-rw-r--r--src/settings/nm-settings.c15
-rw-r--r--src/settings/plugins/ifcfg-rh/shvar.c3
-rw-r--r--src/settings/plugins/ifupdown/parser.c4
-rw-r--r--src/settings/plugins/ifupdown/tests/test-ifupdown.c14
26 files changed, 69 insertions, 108 deletions
diff --git a/callouts/nm-dispatcher-action.c b/callouts/nm-dispatcher-action.c
index d37a08e1b2..397f2bac3e 100644
--- a/callouts/nm-dispatcher-action.c
+++ b/callouts/nm-dispatcher-action.c
@@ -121,8 +121,10 @@ struct Request {
};
static void
-script_info_free (ScriptInfo *info)
+script_info_free (gpointer ptr)
{
+ ScriptInfo *info = ptr;
+
g_free (info->script);
g_free (info->error);
g_free (info);
@@ -134,10 +136,8 @@ request_free (Request *request)
g_free (request->action);
g_free (request->iface);
g_strfreev (request->envp);
- if (request->scripts) {
- g_ptr_array_foreach (request->scripts, (GFunc) script_info_free, NULL);
+ if (request->scripts)
g_ptr_array_free (request->scripts, TRUE);
- }
}
static gboolean
@@ -464,7 +464,7 @@ impl_dispatch (Handler *h,
request->iface = g_strdup (iface);
- request->scripts = g_ptr_array_sized_new (5);
+ request->scripts = g_ptr_array_new_full (5, script_info_free);
for (iter = sorted_scripts; iter; iter = g_slist_next (iter)) {
ScriptInfo *s = g_malloc0 (sizeof (*s));
s->request = request;
diff --git a/callouts/nm-dispatcher-utils.c b/callouts/nm-dispatcher-utils.c
index 4c047da0ed..ee756b648d 100644
--- a/callouts/nm-dispatcher-utils.c
+++ b/callouts/nm-dispatcher-utils.c
@@ -130,10 +130,8 @@ construct_ip4_items (GSList *items, GHashTable *ip4_config, const char *prefix)
}
if (num)
items = g_slist_prepend (items, g_strdup_printf ("%sIP4_NUM_ADDRESSES=%d", prefix, num));
- if (addresses) {
- g_slist_foreach (addresses, (GFunc) nm_ip4_address_unref, NULL);
- g_slist_free (addresses);
- }
+ if (addresses)
+ g_slist_free_full (addresses, (GDestroyNotify) nm_ip4_address_unref);
/* DNS servers */
val = g_hash_table_lookup (ip4_config, "nameservers");
@@ -219,10 +217,8 @@ construct_ip4_items (GSList *items, GHashTable *ip4_config, const char *prefix)
items = g_slist_prepend (items, routetmp);
}
items = g_slist_prepend (items, g_strdup_printf ("%sIP4_NUM_ROUTES=%d", prefix, num));
- if (routes) {
- g_slist_foreach (routes, (GFunc) nm_ip4_route_unref, NULL);
- g_slist_free (routes);
- }
+ if (routes)
+ g_slist_free_full (routes, (GDestroyNotify) nm_ip4_route_unref);
return items;
}
@@ -289,10 +285,8 @@ construct_ip6_items (GSList *items, GHashTable *ip6_config, const char *prefix)
}
if (num)
items = g_slist_prepend (items, g_strdup_printf ("%sIP6_NUM_ADDRESSES=%d", prefix, num));
- if (addresses) {
- g_slist_foreach (addresses, (GFunc) nm_ip6_address_unref, NULL);
- g_slist_free (addresses);
- }
+ if (addresses)
+ g_slist_free_full (addresses, (GDestroyNotify) nm_ip6_address_unref);
/* DNS servers */
val = g_hash_table_lookup (ip6_config, "nameservers");
@@ -352,10 +346,8 @@ construct_ip6_items (GSList *items, GHashTable *ip6_config, const char *prefix)
}
if (num)
items = g_slist_prepend (items, g_strdup_printf ("%sIP6_NUM_ROUTES=%d", prefix, num));
- if (routes) {
- g_slist_foreach (routes, (GFunc) nm_ip6_route_unref, NULL);
- g_slist_free (routes);
- }
+ if (routes)
+ g_slist_free_full (routes, (GDestroyNotify) nm_ip6_route_unref);
return items;
}
diff --git a/cli/src/connections.c b/cli/src/connections.c
index 7c69f37809..d27fae88bf 100644
--- a/cli/src/connections.c
+++ b/cli/src/connections.c
@@ -389,7 +389,7 @@ nmc_connection_detail (NMConnection *connection, NmCli *nmc)
}
static void
-fill_output_connection (NMConnection *data, gpointer user_data)
+fill_output_connection (gpointer data, gpointer user_data)
{
NMConnection *connection = (NMConnection *) data;
NmCli *nmc = (NmCli *) user_data;
@@ -502,7 +502,7 @@ do_connections_show (NmCli *nmc, int argc, char **argv)
g_ptr_array_add (nmc->output_data, arr);
/* Add values */
- g_slist_foreach (nmc->system_connections, (GFunc) fill_output_connection, nmc);
+ g_slist_foreach (nmc->system_connections, fill_output_connection, nmc);
print_data (nmc); /* Print all data */
} else {
g_clear_error (&error1); /* the error1 is only relevant for 'show configured' without arguments */
diff --git a/examples/C/glib/list-connections-libnm-glib.c b/examples/C/glib/list-connections-libnm-glib.c
index 01a9f254e1..921dd683c2 100644
--- a/examples/C/glib/list-connections-libnm-glib.c
+++ b/examples/C/glib/list-connections-libnm-glib.c
@@ -67,7 +67,7 @@ setup_signals (void)
/* Print details of connection */
static void
-show_connection (NMConnection *data, gpointer user_data)
+show_connection (gpointer data, gpointer user_data)
{
NMConnection *connection = (NMConnection *) data;
NMSettingConnection *s_con;
@@ -107,7 +107,7 @@ get_connections_cb (NMRemoteSettings *settings, gpointer user_data)
printf ("Connections:\n===================\n");
- g_slist_foreach (connections, (GFunc) show_connection, NULL);
+ g_slist_foreach (connections, show_connection, NULL);
g_slist_free (connections);
g_object_unref (settings);
diff --git a/libnm-glib/libnm_glib.c b/libnm-glib/libnm_glib.c
index 1d75578612..2abd6ab881 100644
--- a/libnm-glib/libnm_glib.c
+++ b/libnm-glib/libnm_glib.c
@@ -456,8 +456,7 @@ _libnm_glib_ctx_free (libnm_glib_ctx *ctx)
if (ctx->callbacks_lock)
g_mutex_free (ctx->callbacks_lock);
- g_slist_foreach (ctx->callbacks, (GFunc)g_free, NULL);
- g_slist_free (ctx->callbacks);
+ g_slist_free_full (ctx->callbacks, g_free);
if (ctx->thread)
g_thread_join (ctx->thread);
diff --git a/libnm-glib/nm-active-connection.c b/libnm-glib/nm-active-connection.c
index 6b3c782154..c4744837bd 100644
--- a/libnm-glib/nm-active-connection.c
+++ b/libnm-glib/nm-active-connection.c
@@ -354,7 +354,7 @@ dispose (GObject *object)
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object);
if (priv->devices) {
- g_ptr_array_foreach (priv->devices, (GFunc) g_object_unref, NULL);
+ g_ptr_array_set_free_func (priv->devices, g_object_unref);
g_ptr_array_free (priv->devices, TRUE);
priv->devices = NULL;
}
diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c
index 15c708acc1..c424037bc0 100644
--- a/libnm-glib/nm-client.c
+++ b/libnm-glib/nm-client.c
@@ -2034,8 +2034,7 @@ dispose (GObject *object)
g_clear_object (&priv->primary_connection);
g_clear_object (&priv->activating_connection);
- g_slist_foreach (priv->pending_activations, (GFunc) activate_info_free, NULL);
- g_slist_free (priv->pending_activations);
+ g_slist_free_full (priv->pending_activations, (GDestroyNotify) activate_info_free);
priv->pending_activations = NULL;
g_hash_table_destroy (priv->permissions);
diff --git a/libnm-glib/nm-device-bond.c b/libnm-glib/nm-device-bond.c
index 04188a43bf..18c10484d0 100644
--- a/libnm-glib/nm-device-bond.c
+++ b/libnm-glib/nm-device-bond.c
@@ -238,7 +238,7 @@ dispose (GObject *object)
g_clear_object (&priv->proxy);
if (priv->slaves) {
- g_ptr_array_foreach (priv->slaves, (GFunc) g_object_unref, NULL);
+ g_ptr_array_set_free_func (priv->slaves, g_object_unref);
g_ptr_array_free (priv->slaves, TRUE);
priv->slaves = NULL;
}
diff --git a/libnm-glib/nm-device-bridge.c b/libnm-glib/nm-device-bridge.c
index e632a9b2ea..2bec00fbfb 100644
--- a/libnm-glib/nm-device-bridge.c
+++ b/libnm-glib/nm-device-bridge.c
@@ -246,7 +246,7 @@ dispose (GObject *object)
g_clear_object (&priv->proxy);
if (priv->slaves) {
- g_ptr_array_foreach (priv->slaves, (GFunc) g_object_unref, NULL);
+ g_ptr_array_set_free_func (priv->slaves, g_object_unref);
g_ptr_array_free (priv->slaves, TRUE);
priv->slaves = NULL;
}
diff --git a/libnm-glib/nm-device-team.c b/libnm-glib/nm-device-team.c
index 67f0d1d44f..adf0113724 100644
--- a/libnm-glib/nm-device-team.c
+++ b/libnm-glib/nm-device-team.c
@@ -234,7 +234,7 @@ dispose (GObject *object)
g_clear_object (&priv->proxy);
if (priv->slaves) {
- g_ptr_array_foreach (priv->slaves, (GFunc) g_object_unref, NULL);
+ g_ptr_array_set_free_func (priv->slaves, g_object_unref);
g_ptr_array_free (priv->slaves, TRUE);
priv->slaves = NULL;
}
diff --git a/libnm-glib/nm-ip4-config.c b/libnm-glib/nm-ip4-config.c
index 0fc3a1fd86..ec523a0333 100644
--- a/libnm-glib/nm-ip4-config.c
+++ b/libnm-glib/nm-ip4-config.c
@@ -69,8 +69,7 @@ demarshal_ip4_address_array (NMObject *object, GParamSpec *pspec, GValue *value,
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
- g_slist_foreach (priv->addresses, (GFunc) nm_ip4_address_unref, NULL);
- g_slist_free (priv->addresses);
+ g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip4_address_unref);
priv->addresses = NULL;
priv->addresses = nm_utils_ip4_addresses_from_gvalue (value);
@@ -108,8 +107,7 @@ demarshal_ip4_routes_array (NMObject *object, GParamSpec *pspec, GValue *value,
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
- g_slist_foreach (priv->routes, (GFunc) nm_ip4_route_unref, NULL);
- g_slist_free (priv->routes);
+ g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip4_route_unref);
priv->routes = NULL;
priv->routes = nm_utils_ip4_routes_from_gvalue (value);
@@ -156,11 +154,8 @@ finalize (GObject *object)
g_free (priv->gateway);
- g_slist_foreach (priv->addresses, (GFunc) nm_ip4_address_unref, NULL);
- g_slist_free (priv->addresses);
-
- g_slist_foreach (priv->routes, (GFunc) nm_ip4_route_unref, NULL);
- g_slist_free (priv->routes);
+ g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip4_address_unref);
+ g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip4_route_unref);
if (priv->nameservers)
g_array_free (priv->nameservers, TRUE);
@@ -169,12 +164,12 @@ finalize (GObject *object)
g_array_free (priv->wins, TRUE);
if (priv->domains) {
- g_ptr_array_foreach (priv->domains, (GFunc) g_free, NULL);
+ g_ptr_array_set_free_func (priv->domains, g_free);
g_ptr_array_free (priv->domains, TRUE);
}
if (priv->searches) {
- g_ptr_array_foreach (priv->searches, (GFunc) g_free, NULL);
+ g_ptr_array_set_free_func (priv->searches, g_free);
g_ptr_array_free (priv->searches, TRUE);
}
diff --git a/libnm-glib/nm-ip6-config.c b/libnm-glib/nm-ip6-config.c
index cd717c095c..01e2cae5f8 100644
--- a/libnm-glib/nm-ip6-config.c
+++ b/libnm-glib/nm-ip6-config.c
@@ -80,8 +80,7 @@ demarshal_ip6_address_array (NMObject *object, GParamSpec *pspec, GValue *value,
{
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object);
- g_slist_foreach (priv->addresses, (GFunc) nm_ip6_address_unref, NULL);
- g_slist_free (priv->addresses);
+ g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip6_address_unref);
priv->addresses = NULL;
priv->addresses = nm_utils_ip6_addresses_from_gvalue (value);
@@ -127,8 +126,7 @@ demarshal_ip6_routes_array (NMObject *object, GParamSpec *pspec, GValue *value,
{
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object);
- g_slist_foreach (priv->routes, (GFunc) nm_ip6_route_unref, NULL);
- g_slist_free (priv->routes);
+ g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip6_route_unref);
priv->routes = NULL;
priv->routes = nm_utils_ip6_routes_from_gvalue (value);
@@ -289,22 +287,17 @@ finalize (GObject *object)
g_free (priv->gateway);
- g_slist_foreach (priv->addresses, (GFunc) nm_ip6_address_unref, NULL);
- g_slist_free (priv->addresses);
-
- g_slist_foreach (priv->routes, (GFunc) nm_ip6_route_unref, NULL);
- g_slist_free (priv->routes);
-
- g_slist_foreach (priv->nameservers, (GFunc) g_free, NULL);
- g_slist_free (priv->nameservers);
+ g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip6_address_unref);
+ g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip6_route_unref);
+ g_slist_free_full (priv->nameservers, g_free);
if (priv->domains) {
- g_ptr_array_foreach (priv->domains, (GFunc) g_free, NULL);
+ g_ptr_array_set_free_func (priv->domains, g_free);
g_ptr_array_free (priv->domains, TRUE);
}
if (priv->searches) {
- g_ptr_array_foreach (priv->searches, (GFunc) g_free, NULL);
+ g_ptr_array_set_free_func (priv->searches, g_free);
g_ptr_array_free (priv->searches, TRUE);
}
diff --git a/libnm-glib/nm-object.c b/libnm-glib/nm-object.c
index 6424e29cff..e58b020501 100644
--- a/libnm-glib/nm-object.c
+++ b/libnm-glib/nm-object.c
@@ -317,12 +317,10 @@ dispose (GObject *object)
priv->notify_id = 0;
}
- g_slist_foreach (priv->notify_props, (GFunc) g_free, NULL);
- g_slist_free (priv->notify_props);
+ g_slist_free_full (priv->notify_props, g_free);
priv->notify_props = NULL;
- g_slist_foreach (priv->property_interfaces, (GFunc) g_free, NULL);
- g_slist_free (priv->property_interfaces);
+ g_slist_free_full (priv->property_interfaces, g_free);
priv->property_interfaces = NULL;
g_clear_object (&priv->properties_proxy);
@@ -341,8 +339,7 @@ finalize (GObject *object)
{
NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
- g_slist_foreach (priv->property_tables, (GFunc) g_hash_table_destroy, NULL);
- g_slist_free (priv->property_tables);
+ g_slist_free_full (priv->property_tables, (GDestroyNotify) g_hash_table_destroy);
g_free (priv->path);
if (priv->pseudo_properties)
diff --git a/libnm-glib/nm-types.c b/libnm-glib/nm-types.c
index 098af8d8ec..f9ba6d240b 100644
--- a/libnm-glib/nm-types.c
+++ b/libnm-glib/nm-types.c
@@ -363,8 +363,7 @@ _nm_ip6_address_array_demarshal (GValue *value, GSList **dest)
return FALSE;
if (*dest) {
- g_slist_foreach (*dest, (GFunc) g_free, NULL);
- g_slist_free (*dest);
+ g_slist_free_full (*dest, g_free);
*dest = NULL;
}
diff --git a/libnm-util/nm-param-spec-specialized.c b/libnm-util/nm-param-spec-specialized.c
index 9a671a2e87..9f64df335a 100644
--- a/libnm-util/nm-param-spec-specialized.c
+++ b/libnm-util/nm-param-spec-specialized.c
@@ -291,10 +291,8 @@ _gvalues_compare_collection (const GValue *value1, const GValue *value2)
ret = _gvalues_compare ((GValue *) iter1->data, (GValue *) iter2->data);
}
- g_slist_foreach (list1, (GFunc) _gvalue_destroy, NULL);
- g_slist_free (list1);
- g_slist_foreach (list2, (GFunc) _gvalue_destroy, NULL);
- g_slist_free (list2);
+ g_slist_free_full (list1, _gvalue_destroy);
+ g_slist_free_full (list2, _gvalue_destroy);
}
return ret;
diff --git a/libnm-util/nm-setting-vpn.c b/libnm-util/nm-setting-vpn.c
index 0e82295276..7af84cc912 100644
--- a/libnm-util/nm-setting-vpn.c
+++ b/libnm-util/nm-setting-vpn.c
@@ -267,8 +267,7 @@ foreach_item_helper (GHashTable *hash,
func (siter->data, value, user_data);
}
- g_slist_foreach (copied, (GFunc) g_free, NULL);
- g_slist_free (copied);
+ g_slist_free_full (copied, g_free);
}
/**
diff --git a/libnm-util/nm-setting-wired.c b/libnm-util/nm-setting-wired.c
index 8102f7a4e8..7c2a0d4781 100644
--- a/libnm-util/nm-setting-wired.c
+++ b/libnm-util/nm-setting-wired.c
@@ -674,7 +674,7 @@ finalize (GObject *object)
g_slist_free_full (priv->mac_address_blacklist, g_free);
if (priv->s390_subchannels) {
- g_ptr_array_foreach (priv->s390_subchannels, (GFunc) g_free, NULL);
+ g_ptr_array_set_free_func (priv->s390_subchannels, g_free);
g_ptr_array_free (priv->s390_subchannels, TRUE);
}
@@ -728,7 +728,7 @@ set_property (GObject *object, guint prop_id,
break;
case PROP_S390_SUBCHANNELS:
if (priv->s390_subchannels) {
- g_ptr_array_foreach (priv->s390_subchannels, (GFunc) g_free, NULL);
+ g_ptr_array_set_free_func (priv->s390_subchannels, g_free);
g_ptr_array_free (priv->s390_subchannels, TRUE);
}
priv->s390_subchannels = g_value_dup_boxed (value);
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index d0f669cec3..7dc536ce9a 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -6412,13 +6412,11 @@ ip4_match_config (NMDevice *self, NMConnection *connection)
break;
}
}
- g_slist_foreach (leases, (GFunc) g_object_unref, NULL);
- g_slist_free (leases);
+ g_slist_free_full (leases, g_object_unref);
return found;
} else {
/* Maybe the connection used to be DHCP and there are stale leases; ignore them */
- g_slist_foreach (leases, (GFunc) g_object_unref, NULL);
- g_slist_free (leases);
+ g_slist_free_full (leases, g_object_unref);
}
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) {
diff --git a/src/devices/wimax/nm-device-wimax.c b/src/devices/wimax/nm-device-wimax.c
index ab3c10905c..da92e014c4 100644
--- a/src/devices/wimax/nm-device-wimax.c
+++ b/src/devices/wimax/nm-device-wimax.c
@@ -1349,8 +1349,7 @@ dispose (GObject *object)
set_current_nsp (self, NULL);
- g_slist_foreach (priv->nsp_list, (GFunc) g_object_unref, NULL);
- g_slist_free (priv->nsp_list);
+ g_slist_free_full (priv->nsp_list, g_object_unref);
iwmx_sdk_new_callback_unregister (wmx_new_sdk_cb, self);
nm_wimax_util_sdk_unref ();
diff --git a/src/nm-dbus-manager.c b/src/nm-dbus-manager.c
index ca2182d325..891a765f46 100644
--- a/src/nm-dbus-manager.c
+++ b/src/nm-dbus-manager.c
@@ -214,8 +214,10 @@ private_server_new (const char *path,
}
static void
-private_server_free (PrivateServer *s)
+private_server_free (gpointer ptr)
{
+ PrivateServer *s = ptr;
+
unlink (s->address);
g_free (s->address);
g_free (s->tag);
@@ -472,8 +474,7 @@ nm_dbus_manager_dispose (GObject *object)
priv->exported = NULL;
}
- g_slist_foreach (priv->private_servers, (GFunc) private_server_free, NULL);
- g_slist_free (priv->private_servers);
+ g_slist_free_full (priv->private_servers, private_server_free);
priv->private_servers = NULL;
priv->priv_server = NULL;
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 8427c20589..073783473d 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -4501,8 +4501,7 @@ dispose (GObject *object)
}
priv->disposed = TRUE;
- g_slist_foreach (priv->auth_chains, (GFunc) nm_auth_chain_unref, NULL);
- g_slist_free (priv->auth_chains);
+ g_slist_free_full (priv->auth_chains, (GDestroyNotify) nm_auth_chain_unref);
nm_auth_changed_func_unregister (authority_changed_cb, manager);
diff --git a/src/settings/nm-secret-agent.c b/src/settings/nm-secret-agent.c
index 5a8a73fc4b..7f0e879a3a 100644
--- a/src/settings/nm-secret-agent.c
+++ b/src/settings/nm-secret-agent.c
@@ -509,8 +509,7 @@ dispose (GObject *object)
g_free (priv->identifier);
g_free (priv->owner_username);
- g_slist_foreach (priv->permissions, (GFunc) g_free, NULL);
- g_slist_free (priv->permissions);
+ g_slist_free_full (priv->permissions, g_free);
g_hash_table_destroy (priv->requests);
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
index 4163d35bd0..2898888add 100644
--- a/src/settings/nm-settings.c
+++ b/src/settings/nm-settings.c
@@ -361,8 +361,7 @@ clear_unmanaged_specs (NMSettings *self)
{
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
- g_slist_foreach (priv->unmanaged_specs, (GFunc) g_free, NULL);
- g_slist_free (priv->unmanaged_specs);
+ g_slist_free_full (priv->unmanaged_specs, g_free);
priv->unmanaged_specs = NULL;
}
@@ -658,8 +657,7 @@ load_plugins (NMSettings *self, const char **plugins, GError **error)
if (!keyfile_added)
add_keyfile_plugin (self);
- g_slist_foreach (list, (GFunc) g_object_unref, NULL);
- g_slist_free (list);
+ g_slist_free_full (list, g_object_unref);
return success;
}
@@ -1732,11 +1730,9 @@ dispose (GObject *object)
{
NMSettings *self = NM_SETTINGS (object);
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
- GSList *iter;
- for (iter = priv->auths; iter; iter = g_slist_next (iter))
- nm_auth_chain_unref ((NMAuthChain *) iter->data);
- g_slist_free (priv->auths);
+ g_slist_free_full (priv->auths, (GDestroyNotify) nm_auth_chain_unref);
+ priv->auths = NULL;
priv->dbus_mgr = NULL;
@@ -1757,8 +1753,7 @@ finalize (GObject *object)
clear_unmanaged_specs (self);
- g_slist_foreach (priv->plugins, (GFunc) g_object_unref, NULL);
- g_slist_free (priv->plugins);
+ g_slist_free_full (priv->plugins, g_object_unref);
G_OBJECT_CLASS (nm_settings_parent_class)->finalize (object);
}
diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c
index 653bc930da..7e64816c17 100644
--- a/src/settings/plugins/ifcfg-rh/shvar.c
+++ b/src/settings/plugins/ifcfg-rh/shvar.c
@@ -392,8 +392,7 @@ svCloseFile(shvarFile *s)
g_free(s->arena);
g_free(s->fileName);
- g_list_foreach (s->lineList, (GFunc) g_free, NULL);
- g_list_free(s->lineList); /* implicitly frees s->current */
+ g_list_free_full (s->lineList, g_free); /* implicitly frees s->current */
g_free(s);
return 0;
}
diff --git a/src/settings/plugins/ifupdown/parser.c b/src/settings/plugins/ifupdown/parser.c
index 5ab2d854f4..9348523f87 100644
--- a/src/settings/plugins/ifupdown/parser.c
+++ b/src/settings/plugins/ifupdown/parser.c
@@ -240,9 +240,7 @@ string_to_glist_of_strings(const gchar* data)
static void
slist_free_all(gpointer slist)
{
- GSList *list = (GSList *) slist;
- g_slist_foreach (list, (GFunc) g_free, NULL);
- g_slist_free (list);
+ g_slist_free_full ((GSList *) slist, g_free);
}
static void
diff --git a/src/settings/plugins/ifupdown/tests/test-ifupdown.c b/src/settings/plugins/ifupdown/tests/test-ifupdown.c
index 506789fc05..1040099a31 100644
--- a/src/settings/plugins/ifupdown/tests/test-ifupdown.c
+++ b/src/settings/plugins/ifupdown/tests/test-ifupdown.c
@@ -57,8 +57,10 @@ expected_key_new (const char *key, const char *data)
}
static void
-expected_key_free (ExpectedKey *k)
+expected_key_free (gpointer ptr)
{
+ ExpectedKey *k = ptr;
+
g_assert (k);
g_free (k->key);
g_free (k->data);
@@ -81,11 +83,12 @@ expected_block_new (const char *type, const char *name)
}
static void
-expected_block_free (ExpectedBlock *b)
+expected_block_free (gpointer ptr)
{
+ ExpectedBlock *b = ptr;
+
g_assert (b);
- g_slist_foreach (b->keys, (GFunc) expected_key_free, NULL);
- g_slist_free (b->keys);
+ g_slist_free_full (b->keys, expected_key_free);
g_free (b->type);
g_free (b->name);
memset (b, 0, sizeof (ExpectedBlock));
@@ -122,8 +125,7 @@ static void
expected_free (Expected *e)
{
g_assert (e);
- g_slist_foreach (e->blocks, (GFunc) expected_block_free, NULL);
- g_slist_free (e->blocks);
+ g_slist_free_full (e->blocks, expected_block_free);
memset (e, 0, sizeof (Expected));
g_free (e);
}