summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-07-27 23:55:55 +0200
committerThomas Haller <thaller@redhat.com>2014-07-27 23:55:55 +0200
commit83cda23e93a58753fc4fea842f43350a7db35e2f (patch)
treeda47f7f13ec8224a7b03c0e78cf2137875de8641
parentcdc756c9c95fffc6b1cd5d36b342b152c7da3348 (diff)
downloadNetworkManager-83cda23e93a58753fc4fea842f43350a7db35e2f.tar.gz
all: use nm_intern_utils_hash_values_to_slist()
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--libnm-glib/nm-remote-settings.c18
-rw-r--r--src/settings/nm-settings-connection.c13
-rw-r--r--src/settings/nm-settings.c9
-rw-r--r--src/settings/plugins/ifupdown/plugin.c10
-rw-r--r--src/settings/plugins/keyfile/plugin.c11
5 files changed, 14 insertions, 47 deletions
diff --git a/libnm-glib/nm-remote-settings.c b/libnm-glib/nm-remote-settings.c
index 49d7780e6e..0c2c44fab5 100644
--- a/libnm-glib/nm-remote-settings.c
+++ b/libnm-glib/nm-remote-settings.c
@@ -30,6 +30,7 @@
#include "nm-dbus-helpers-private.h"
#include "nm-glib-compat.h"
#include "nm-object-private.h"
+#include "nm-utils-internal.h"
/**
* SECTION:nm-remote-settings
@@ -607,8 +608,6 @@ nm_remote_settings_list_connections (NMRemoteSettings *settings)
{
NMRemoteSettingsPrivate *priv;
GSList *list = NULL;
- GHashTableIter iter;
- gpointer value;
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), NULL);
@@ -616,11 +615,8 @@ nm_remote_settings_list_connections (NMRemoteSettings *settings)
_nm_remote_settings_ensure_inited (settings);
- if (priv->service_running) {
- g_hash_table_iter_init (&iter, priv->connections);
- while (g_hash_table_iter_next (&iter, NULL, &value))
- list = g_slist_prepend (list, NM_REMOTE_CONNECTION (value));
- }
+ if (priv->service_running)
+ list = nm_intern_utils_hash_values_to_slist (priv->connections);
return list;
}
@@ -871,18 +867,14 @@ nm_remote_settings_reload_connections (NMRemoteSettings *settings,
static void
clear_one_hash (GHashTable *table)
{
- GHashTableIter iter;
- gpointer value;
- GSList *list = NULL, *list_iter;
+ GSList *list, *list_iter;
/* Build up the list of connections; we can't emit "removed" during hash
* table iteration because emission of the "removed" signal may trigger code
* that explicitly removes the connection from the hash table somewhere
* else.
*/
- g_hash_table_iter_init (&iter, table);
- while (g_hash_table_iter_next (&iter, NULL, &value))
- list = g_slist_prepend (list, NM_REMOTE_CONNECTION (value));
+ list = nm_intern_utils_hash_values_to_slist (table);
for (list_iter = list; list_iter; list_iter = g_slist_next (list_iter))
g_signal_emit_by_name (NM_REMOTE_CONNECTION (list_iter->data), NM_REMOTE_CONNECTION_REMOVED);
diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c
index 5bf8c31b34..3bf10e2feb 100644
--- a/src/settings/nm-settings-connection.c
+++ b/src/settings/nm-settings-connection.c
@@ -29,7 +29,7 @@
#include <nm-setting-connection.h>
#include <nm-setting-vpn.h>
#include <nm-setting-wireless.h>
-#include <nm-utils.h>
+#include <nm-utils-internal.h>
#include "nm-settings-connection.h"
#include "nm-session-monitor.h"
@@ -1755,18 +1755,9 @@ mac_dup (const struct ether_addr *old)
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_intern_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 3a833db0c9..0b3aa07c31 100644
--- a/src/settings/nm-settings.c
+++ b/src/settings/nm-settings.c
@@ -51,7 +51,7 @@
#include <nm-setting-wireless.h>
#include <nm-setting-wireless-security.h>
#include <nm-setting-bond.h>
-#include <nm-utils.h>
+#include <nm-utils-internal.h>
#include "nm-device-ethernet.h"
#include "nm-dbus-glib-types.h"
@@ -1769,13 +1769,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_intern_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 dcae211c45..fbaf8430a1 100644
--- a/src/settings/plugins/ifupdown/plugin.c
+++ b/src/settings/plugins/ifupdown/plugin.c
@@ -42,7 +42,7 @@
#include "nm-setting-wireless.h"
#include "nm-setting-wired.h"
#include "nm-setting-ppp.h"
-#include "nm-utils.h"
+#include "nm-utils-internal.h"
#include "nm-ifupdown-connection.h"
#include "plugin.h"
@@ -507,9 +507,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));
@@ -518,9 +516,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_intern_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 10c8397180..331836e8da 100644
--- a/src/settings/plugins/keyfile/plugin.c
+++ b/src/settings/plugins/keyfile/plugin.c
@@ -34,7 +34,7 @@
#include <nm-connection.h>
#include <nm-setting.h>
#include <nm-setting-connection.h>
-#include <nm-utils.h>
+#include <nm-utils-internal.h>
#include <nm-config.h>
#include <nm-logging.h>
@@ -373,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_intern_utils_hash_values_to_slist (priv->connections);
}
static gboolean