summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-07-27 23:55:55 +0200
committerThomas Haller <thaller@redhat.com>2014-08-22 15:24:30 +0200
commite478d1fb71634bbf49cb0bea5990e2ceb961c144 (patch)
treee8359a836d9c936719f31d6cfdfd3ad9bf07086c
parentff142ce780c8d524b54431db1a523ee36fc1867a (diff)
downloadNetworkManager-e478d1fb71634bbf49cb0bea5990e2ceb961c144.tar.gz
all: use _nm_utils_hash_values_to_slist()
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--src/settings/nm-settings-connection.c18
-rw-r--r--src/settings/nm-settings.c8
-rw-r--r--src/settings/plugins/ifupdown/plugin.c9
-rw-r--r--src/settings/plugins/keyfile/plugin.c10
4 files changed, 12 insertions, 33 deletions
diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c
index d0a4f7ddb1..3a2b5ac20e 100644
--- a/src/settings/nm-settings-connection.c
+++ b/src/settings/nm-settings-connection.c
@@ -29,6 +29,7 @@
#include <nm-setting-vpn.h>
#include <nm-setting-wireless.h>
#include <nm-utils.h>
+#include "nm-core-internal.h"
#include "nm-settings-connection.h"
#include "nm-session-monitor.h"
@@ -1162,7 +1163,7 @@ get_settings_auth_cb (NMSettingsConnection *self,
s_wifi = nm_connection_get_setting_wireless (NM_CONNECTION (dupl_con));
if (bssid_list && s_wifi)
g_object_set (s_wifi, NM_SETTING_WIRELESS_SEEN_BSSIDS, bssid_list, NULL);
- g_slist_free_full (bssid_list, g_free);
+ g_slist_free (bssid_list);
/* 802-11-wireless.security property is deprecated. But we set it here so that
* we don't disturb old clients that might expect it being properly set for
@@ -1745,24 +1746,15 @@ mac_dup (const guint8 *old)
*
* Returns current list of seen BSSIDs for the connection.
*
- * Returns: (transfer full) list of seen BSSIDs (in the standard hex-digits-and-colons notation).
- * The caller is responsible for freeing the list.
+ * Returns: (transfer container) list of seen BSSIDs (in the standard hex-digits-and-colons notation).
+ * The caller is responsible for freeing the list, but not the content.
**/
GSList *
nm_settings_connection_get_seen_bssids (NMSettingsConnection *connection)
{
- NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection);
- GHashTableIter iter;
- char *bssid_str;
- GSList *bssid_list = NULL;
-
g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (connection), NULL);
- g_hash_table_iter_init (&iter, priv->seen_bssids);
- while (g_hash_table_iter_next (&iter, NULL, (gpointer) &bssid_str))
- bssid_list = g_slist_prepend (bssid_list, g_strdup (bssid_str));
-
- return bssid_list;
+ return _nm_utils_hash_values_to_slist (NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->seen_bssids);
}
/**
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
index edc4fa9fb4..3e186eaa52 100644
--- a/src/settings/nm-settings.c
+++ b/src/settings/nm-settings.c
@@ -52,6 +52,7 @@
#include <nm-setting-wireless-security.h>
#include <nm-setting-bond.h>
#include <nm-utils.h>
+#include "nm-core-internal.h"
#include "nm-device-ethernet.h"
#include "nm-dbus-glib-types.h"
@@ -1763,13 +1764,8 @@ get_connections (NMConnectionProvider *provider)
GSList *list = NULL;
NMSettings *self = NM_SETTINGS (provider);
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
- GHashTableIter iter;
- NMSettingsConnection *connection;
- g_hash_table_iter_init (&iter, priv->connections);
- while (g_hash_table_iter_next (&iter, NULL, (gpointer) &connection))
- list = g_slist_prepend (list, connection);
- list = g_slist_reverse (list);
+ list = _nm_utils_hash_values_to_slist (priv->connections);
/* Cache the list every call so we can keep it 'const' for callers */
g_slist_free (priv->get_connections_cache);
diff --git a/src/settings/plugins/ifupdown/plugin.c b/src/settings/plugins/ifupdown/plugin.c
index 7ef7c51b54..ba15c3e3fa 100644
--- a/src/settings/plugins/ifupdown/plugin.c
+++ b/src/settings/plugins/ifupdown/plugin.c
@@ -41,6 +41,7 @@
#include "nm-setting-wired.h"
#include "nm-setting-ppp.h"
#include "nm-utils.h"
+#include "nm-core-internal.h"
#include "nm-ifupdown-connection.h"
#include "plugin.h"
@@ -505,9 +506,7 @@ static GSList*
SCPluginIfupdown_get_connections (NMSystemConfigInterface *config)
{
SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (config);
- GSList *connections = NULL;
- GHashTableIter iter;
- gpointer value;
+ GSList *connections;
nm_log_info (LOGD_SETTINGS, "(%d) ... get_connections.", GPOINTER_TO_UINT(config));
@@ -516,9 +515,7 @@ SCPluginIfupdown_get_connections (NMSystemConfigInterface *config)
return NULL;
}
- g_hash_table_iter_init (&iter, priv->connections);
- while (g_hash_table_iter_next (&iter, NULL, &value))
- connections = g_slist_prepend (connections, value);
+ connections = _nm_utils_hash_values_to_slist (priv->connections);
nm_log_info (LOGD_SETTINGS, "(%d) connections count: %d", GPOINTER_TO_UINT(config), g_slist_length(connections));
return connections;
diff --git a/src/settings/plugins/keyfile/plugin.c b/src/settings/plugins/keyfile/plugin.c
index a1c776c0e0..562beeaeb1 100644
--- a/src/settings/plugins/keyfile/plugin.c
+++ b/src/settings/plugins/keyfile/plugin.c
@@ -36,6 +36,7 @@
#include <nm-utils.h>
#include <nm-config.h>
#include <nm-logging.h>
+#include "nm-core-internal.h"
#include "plugin.h"
#include "nm-system-config-interface.h"
@@ -372,20 +373,13 @@ static GSList *
get_connections (NMSystemConfigInterface *config)
{
SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (config);
- GHashTableIter iter;
- gpointer data = NULL;
- GSList *list = NULL;
if (!priv->initialized) {
setup_monitoring (config);
read_connections (config);
priv->initialized = TRUE;
}
-
- g_hash_table_iter_init (&iter, priv->connections);
- while (g_hash_table_iter_next (&iter, NULL, &data))
- list = g_slist_prepend (list, data);
- return list;
+ return _nm_utils_hash_values_to_slist (priv->connections);
}
static gboolean