[network-manager-applet/jklimes/team: 5/5] team: make algorithm for choosing new team_num deterministic
- From: Jiří Klimeš <jklimes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/jklimes/team: 5/5] team: make algorithm for choosing new team_num deterministic
- Date: Wed, 18 Sep 2013 11:31:40 +0000 (UTC)
commit 4981ac587e821535012952f145eba3f78ca47d7b
Author: Thomas Haller <thaller redhat com>
Date: Wed Sep 18 10:16:51 2013 +0200
team: make algorithm for choosing new team_num deterministic
The previous algorithm for choosing the team_num is not deterministic.
It does neither choose one of
(a) MAX(existing team_nums) + 1
(b) MIN(unused team_nums)
What it actually chooses depends on the order how the existing
connections are returned. For example:
[0 2] => 1
[2 0] => 3
Change it to use (a).
Signed-off-by: Thomas Haller <thaller redhat com>
src/connection-editor/page-team.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/src/connection-editor/page-team.c b/src/connection-editor/page-team.c
index 2e1ac21..88f83ff 100644
--- a/src/connection-editor/page-team.c
+++ b/src/connection-editor/page-team.c
@@ -282,7 +282,7 @@ team_connection_new (GtkWindow *parent,
gpointer user_data)
{
NMConnection *connection;
- int team_num, max_team_num, num;
+ int team_num, num;
GSList *connections, *iter;
NMConnection *conn2;
NMSettingTeam *s_team;
@@ -297,7 +297,7 @@ team_connection_new (GtkWindow *parent,
nm_connection_add_setting (connection, nm_setting_team_new ());
/* Find an available interface name */
- team_num = max_team_num = 0;
+ team_num = 0;
connections = nm_remote_settings_list_connections (settings);
for (iter = connections; iter; iter = iter->next) {
conn2 = iter->data;
@@ -312,10 +312,8 @@ team_connection_new (GtkWindow *parent,
continue;
num = atoi (iface + 4);
- if (num > max_team_num)
- max_team_num = num;
- if (num == team_num)
- team_num = max_team_num + 1;
+ if (team_num <= num)
+ team_num = num + 1;
}
g_slist_free (connections);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]