From: Peter Krempa Date: Mon, 22 Mar 2021 16:00:41 +0000 (+0100) Subject: virJSONValueObjectDeflattenWorker: use g_strsplit instead of virStringSplitCount X-Git-Tag: v7.3.0-rc1~306 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e49eb0aaa7e0338c3824634e116da48e88ebb032;p=thirdparty%2Flibvirt.git virJSONValueObjectDeflattenWorker: use g_strsplit instead of virStringSplitCount The presence of the second element can be checked by looking at it directly. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- diff --git a/src/util/virjson.c b/src/util/virjson.c index 0eff467ec5..d52b99e11b 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -1964,7 +1964,6 @@ virJSONValueObjectDeflattenWorker(const char *key, g_autoptr(virJSONValue) newval = NULL; virJSONValuePtr existobj; g_auto(GStrv) tokens = NULL; - size_t ntokens = 0; /* non-nested keys only need to be copied */ if (!strchr(key, '.')) { @@ -1989,10 +1988,10 @@ virJSONValueObjectDeflattenWorker(const char *key, return 0; } - if (!(tokens = virStringSplitCount(key, ".", 2, &ntokens))) + if (!(tokens = g_strsplit(key, ".", 2))) return -1; - if (ntokens != 2) { + if (!tokens[0] || !tokens[1]) { virReportError(VIR_ERR_INVALID_ARG, _("invalid nested value key '%s'"), key); return -1;