summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-05-22 19:51:35 +0200
committerThomas Haller <thaller@redhat.com>2019-05-23 07:41:44 +0200
commit975d45309f4be66543d779269dfa04050b07b40c (patch)
tree38586c7acf2b26c51ca902ef438118685deecfd8
parent9f11c81b4f3b84026cbf1505baeb9e5b4148bee8 (diff)
downloadNetworkManager-th/libnm-team.tar.gz
libnm/keyfile: don't parse JSON config in keyfile reader twiceth/libnm-team
Commit d6ec009afd7d ('team: normalize invalid configuration during load') let's keyfile reader ignore JSON configs that cannot be parsed. Keep doing that, but don't parse the JSON twice for that. Just set the JSON, and if the setting afterwards does not verify, reset it to NULL. We also get a better error message and in most cases we don't need to parse twice.
-rw-r--r--libnm-core/nm-keyfile.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libnm-core/nm-keyfile.c b/libnm-core/nm-keyfile.c
index 6a4681a3ae..9ac3eb4e18 100644
--- a/libnm-core/nm-keyfile.c
+++ b/libnm-core/nm-keyfile.c
@@ -1619,16 +1619,16 @@ team_config_parser (KeyfileReaderInfo *info, NMSetting *setting, const char *key
gs_free_error GError *error = NULL;
conf = nm_keyfile_plugin_kf_get_string (info->keyfile, setting_name, key, NULL);
+
+ g_object_set (G_OBJECT (setting), key, conf, NULL);
+
if ( conf
- && conf[0]
- && !nm_utils_is_json_object (conf, &error)) {
+ && !nm_setting_verify (setting, NULL, &error)) {
handle_warn (info, key, NM_KEYFILE_WARN_SEVERITY_WARN,
_("ignoring invalid team configuration: %s"),
error->message);
- g_clear_pointer (&conf, g_free);
+ g_object_set (G_OBJECT (setting), key, NULL, NULL);
}
-
- g_object_set (G_OBJECT (setting), key, conf, NULL);
}
static void