From 3a99c343d840b0dca9d64d30b62f7781b3592cb0 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 27 Aug 2018 11:36:51 +0200 Subject: [PATCH] device: don't limit try count in nm_device_ethernet_utils_get_default_wired_name() The limit of trying up to 10000 was arbitrary. In practice, we are not expected that we need that many searches. If that would be the case (and we would have 10000 conflicting connections that take all the names), then we anyway would need to refactor the code not to scale with O(n^2). Replace the arbitrary limit with an even larger one. The new limit is so large that in practice it's impossible to reach it. --- src/devices/nm-device-ethernet-utils.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/devices/nm-device-ethernet-utils.c b/src/devices/nm-device-ethernet-utils.c index 298e6dff9..096380357 100644 --- a/src/devices/nm-device-ethernet-utils.c +++ b/src/devices/nm-device-ethernet-utils.c @@ -32,7 +32,7 @@ nm_device_ethernet_utils_get_default_wired_name (NMConnection *const *connection 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)) { @@ -44,7 +44,6 @@ nm_device_ethernet_utils_get_default_wired_name (NMConnection *const *connection next: ; } - return NULL; }