diff options
| author | Sebastien Bacher <seb128@ubuntu.com> | 2019-01-25 10:52:15 +0100 |
|---|---|---|
| committer | Sebastien Bacher <seb128@ubuntu.com> | 2019-01-25 11:24:27 +0100 |
| commit | e8ac7dacdcf4b38addef4f8ac6ab038f9d29582c (patch) | |
| tree | 017883e210043859ee695250f6285380b795f8e4 /src/devices/nm-device-ethernet-utils.c | |
| parent | b05c072fe2594e0369cbfb00a3fba176d2d309dc (diff) | |
| parent | 1b878e595ff7be634a4800ca6cc506046e49548e (diff) | |
Merge remote-tracking branch 'salsa/master' into disco
Diffstat (limited to 'src/devices/nm-device-ethernet-utils.c')
| -rw-r--r-- | src/devices/nm-device-ethernet-utils.c | 25 |
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; } |