summaryrefslogtreecommitdiff
path: root/clients/cli
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-08-20 15:25:08 +0200
committerThomas Haller <thaller@redhat.com>2019-08-20 15:31:08 +0200
commit0e1748afe149ee75f8047caf1861ec677e7ba988 (patch)
tree332bb9d2431e2004f3b90de6ec66ca618cb57815 /clients/cli
parente1ec22f74b1e942c510239c299bd08f1544934a1 (diff)
downloadNetworkManager-0e1748afe149ee75f8047caf1861ec677e7ba988.tar.gz
cli: cleanup unique_master_iface_ifname()
- use appropriate types for integer variables - rework the confusing loop which would reset the loop-counter to start again.
Diffstat (limited to 'clients/cli')
-rw-r--r--clients/cli/connections.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index cc40beaedc..0e42831c7a 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -3733,22 +3733,22 @@ static char *
unique_master_iface_ifname (const GPtrArray *connections,
const char *try_name)
{
- NMConnection *connection;
char *new_name;
- unsigned num = 1;
- int i = 0;
- const char *ifname = NULL;
+ guint num = 0;
+ guint i;
new_name = g_strdup (try_name);
- while (i < connections->len) {
- connection = NM_CONNECTION (connections->pdata[i]);
- ifname = nm_connection_get_interface_name (connection);
- if (g_strcmp0 (new_name, ifname) == 0) {
+
+again:
+ for (i = 0; i < connections->len; i++) {
+ NMConnection *connection = connections->pdata[i];
+
+ if (nm_streq0 (new_name, nm_connection_get_interface_name (connection))) {
+ num++;
g_free (new_name);
- new_name = g_strdup_printf ("%s%d", try_name, num++);
- i = 0;
- } else
- i++;
+ new_name = g_strdup_printf ("%s%u", try_name, num);
+ goto again;
+ }
}
return new_name;
}