diff options
| author | Michael Biebl <biebl@debian.org> | 2018-09-23 10:10:27 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2018-09-23 10:10:27 +0200 |
| commit | e126f3e804c35480c4f075777430419d6ece23da (patch) | |
| tree | 5d5821ebcda8cd6ac34d2483bb3354910e508930 /src/devices/nm-device-ethernet-utils.c | |
| parent | c240974325c552cad177c457d6ff04e381fd77a3 (diff) | |
New upstream version 1.12.4 upstream/1.12.4
Diffstat (limited to 'src/devices/nm-device-ethernet-utils.c')
| -rw-r--r-- | src/devices/nm-device-ethernet-utils.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/devices/nm-device-ethernet-utils.c b/src/devices/nm-device-ethernet-utils.c index 8bdb1991..298e6dff 100644 --- a/src/devices/nm-device-ethernet-utils.c +++ b/src/devices/nm-device-ethernet-utils.c @@ -18,24 +18,33 @@ #include "nm-default.h" -#include "nm-device-ethernet-utils.h" +#include <string.h> + +#include "nm-connection.h" -#include "settings/nm-settings-connection.h" +#include "nm-device-ethernet-utils.h" char * -nm_device_ethernet_utils_get_default_wired_name (GHashTable *existing_ids) +nm_device_ethernet_utils_get_default_wired_name (NMConnection *const *connections) { char *temp; + guint j; int i; /* Find the next available unique connection name */ - for (i = 1; i <= G_MAXINT; i++) { + for (i = 1; i <= 10000; i++) { temp = g_strdup_printf (_("Wired connection %d"), i); - if ( !existing_ids - || !g_hash_table_contains (existing_ids, temp)) - return temp; - g_free (temp); + for (j = 0; connections[j]; j++) { + if (nm_streq0 (nm_connection_get_id (connections[j]), temp)) { + g_free (temp); + goto next; + } + } + return temp; +next: + ; } + return NULL; } |