about summary refs log tree commit diff
path: root/src/devices/nm-device-ethernet-utils.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2018-10-21 03:00:34 +0200
committerMichael Biebl <biebl@debian.org>2018-10-21 03:00:34 +0200
commit1f85f9683a41ca116af20fd19940576040303080 (patch)
tree54c4ac337fe0b0091772b7ef6a22c715dd985fab /src/devices/nm-device-ethernet-utils.c
parenteca0cfe89a2a7ec88abe9c03075160f46b338137 (diff)
parent5554398639fa9e344bd12205a64874e6436b936e (diff)
Merge branch 'experimental'
Diffstat (limited to 'src/devices/nm-device-ethernet-utils.c')
-rw-r--r--src/devices/nm-device-ethernet-utils.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/devices/nm-device-ethernet-utils.c b/src/devices/nm-device-ethernet-utils.c
index 298e6dff..b18eadfa 100644
--- a/src/devices/nm-device-ethernet-utils.c
+++ b/src/devices/nm-device-ethernet-utils.c
@@ -18,33 +18,24 @@
 
 #include "nm-default.h"
 
-#include <string.h>
-
-#include "nm-connection.h"
-
 #include "nm-device-ethernet-utils.h"
 
+#include "settings/nm-settings-connection.h"
+
 char *
-nm_device_ethernet_utils_get_default_wired_name (NMConnection *const *connections)
+nm_device_ethernet_utils_get_default_wired_name (GHashTable *existing_ids)
 {
 	char *temp;
-	guint j;
 	int i;
 
 	/* Find the next available unique connection name */
-	for (i = 1; i <= 10000; i++) {
+	for (i = 1; i < G_MAXINT; i++) {
 		temp = g_strdup_printf (_("Wired connection %d"), i);
-		for (j = 0; connections[j]; j++) {
-			if (nm_streq0 (nm_connection_get_id (connections[j]), temp)) {
-				g_free (temp);
-				goto next;
-			}
-		}
-		return temp;
-next:
-		;
+		if (   !existing_ids
+		    || !g_hash_table_contains (existing_ids, temp))
+			return temp;
+		g_free (temp);
 	}
-
 	return NULL;
 }