]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virJSONValueObjectDeflattenWorker: use g_strsplit instead of virStringSplitCount
authorPeter Krempa <pkrempa@redhat.com>
Mon, 22 Mar 2021 16:00:41 +0000 (17:00 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 12 Apr 2021 13:55:09 +0000 (15:55 +0200)
The presence of the second element can be checked by looking at it
directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virjson.c

index 0eff467ec5f62b4c14bca20922336cdbd1e08102..d52b99e11b4fa8d5503ed04c43aca578ea75215c 100644 (file)
@@ -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;