summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-04-18 15:36:00 +0200
committerThomas Haller <thaller@redhat.com>2016-04-18 15:50:58 +0200
commit2b69ee8959e8294b4e7165d2fc7d1e1df345ba4d (patch)
tree3f5422f8004d829f5585a19b01ce8b1c44433987
parent5d31a080f34ee7df08b4ba3c9abf4f6b037ee59c (diff)
downloadNetworkManager-bg/team-conf-check-rh1294728.tar.gz
fixup! libnm-core: use jansson to compare and check team configurationsbg/team-conf-check-rh1294728
We expect, that in many cases the strings for _nm_utils_team_config_equal() are equal. E.g., when user updates a connection only changing NMSettingIP4Config, but not touching the team config. It makes sense to check for that first by doing plain string comparison. In that case, we don't need any special Json comparison. Also, adjust the !WITH_JANSSON version, to return the same result as WITH_JANSSON: Before: WITH: _nm_utils_team_config_equal (NULL, "", TRUE) => FALSE WITHOUT: _nm_utils_team_config_equal (NULL, "", TRUE) => TRUE
-rw-r--r--libnm-core/nm-utils.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
index 69e307a761..1a7de119c0 100644
--- a/libnm-core/nm-utils.c
+++ b/libnm-core/nm-utils.c
@@ -4149,14 +4149,16 @@ _nm_utils_team_config_equal (const char *conf1,
void *tmp;
int i;
+ if (nm_streq0 (conf1, conf2))
+ return TRUE;
+
/* A NULL configuration is equivalent to default value '{}' */
json1 = json_loads (conf1 ?: "{}", 0, &jerror);
if (json1)
json2 = json_loads (conf2 ?: "{}", 0, &jerror);
if (!json1 || !json2) {
- /* At least one configuration is invalid, resort to exact string match */
- ret = nm_streq0 (conf1, conf2);
+ ret = FALSE;
goto out;
}
@@ -4226,6 +4228,6 @@ _nm_utils_team_config_equal (const char *conf1,
const char *conf2,
gboolean port_config)
{
- return nm_streq (conf1 ?: "", conf2 ?: "");
+ return nm_streq0 (conf1, conf2);
}
#endif