]> xenbits.xensource.com Git - libvirt.git/commitdiff
Replace open coded virJSONValueArrayAppendString
authorPeter Krempa <pkrempa@redhat.com>
Mon, 20 Dec 2021 13:41:03 +0000 (14:41 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 22 Dec 2021 12:48:35 +0000 (13:48 +0100)
In two instances we've created a string virJSONValue just to append it
to the array. Replace it by use of the virJSONValueArrayAppendString
helper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
src/qemu/qemu_agent.c
src/util/virmacmap.c

index e2107e5cbf77b39bab6c9e39c0ecc8f10ef190c8..cb3bf97415841ff8a93c71986c1d7694a3790e9c 100644 (file)
@@ -1168,9 +1168,7 @@ qemuAgentMakeStringsArray(const char **strings, unsigned int len)
     g_autoptr(virJSONValue) ret = virJSONValueNewArray();
 
     for (i = 0; i < len; i++) {
-        g_autoptr(virJSONValue) str = virJSONValueNewString(strings[i]);
-
-        if (virJSONValueArrayAppend(ret, &str) < 0)
+        if (virJSONValueArrayAppendString(ret, strings[i]) < 0)
             return NULL;
     }
 
index 0b7b758c6d7f5150eadd05a76b96c2c408c47c4a..cf554205a86a892a84b011467b5c277b7f8a0f4f 100644 (file)
@@ -214,9 +214,7 @@ virMACMapHashDumper(void *payload,
     GSList *next;
 
     for (next = macs; next; next = next->next) {
-        g_autoptr(virJSONValue) m = virJSONValueNewString((const char *) next->data);
-
-        if (virJSONValueArrayAppend(arr, &m) < 0)
+        if (virJSONValueArrayAppendString(arr, (const char *) next->data) < 0)
             return -1;
     }