render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
d76c62
From 500025205783acaa29d3c0e020ef8c6ce9579784 Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <500025205783acaa29d3c0e020ef8c6ce9579784@dist-git>
d76c62
From: Peter Krempa <pkrempa@redhat.com>
d76c62
Date: Tue, 4 Feb 2020 15:08:18 +0100
d76c62
Subject: [PATCH] virJSONValueNewArray: Use g_new0 to allocate and remove NULL
d76c62
 checks from callers
d76c62
MIME-Version: 1.0
d76c62
Content-Type: text/plain; charset=UTF-8
d76c62
Content-Transfer-Encoding: 8bit
d76c62
d76c62
Use the glib allocation function that never returns NULL and remove the
d76c62
now dead-code checks from all callers.
d76c62
d76c62
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
(cherry picked from commit d69470a18afa909a18f336e46a1817657b91635e)
d76c62
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1207659
d76c62
Message-Id: <1c666c563fe614b2c61bb47abb6d33dbcab91316.1580824112.git.pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
---
d76c62
 src/locking/lock_daemon.c        |  4 ++--
d76c62
 src/logging/log_handler.c        |  3 +--
d76c62
 src/network/leaseshelper.c       |  6 +-----
d76c62
 src/qemu/qemu_agent.c            |  6 +-----
d76c62
 src/qemu/qemu_backup.c           |  6 ++----
d76c62
 src/qemu/qemu_block.c            |  9 +++------
d76c62
 src/qemu/qemu_blockjob.c         |  3 +--
d76c62
 src/qemu/qemu_checkpoint.c       |  9 +++------
d76c62
 src/qemu/qemu_driver.c           |  3 +--
d76c62
 src/qemu/qemu_firmware.c         | 12 ++++--------
d76c62
 src/qemu/qemu_migration_params.c |  3 +--
d76c62
 src/qemu/qemu_monitor_json.c     |  3 +--
d76c62
 src/rpc/virnetserver.c           |  6 ++----
d76c62
 src/rpc/virnetserverservice.c    |  3 +--
d76c62
 src/util/virjson.c               | 13 ++-----------
d76c62
 src/util/virlockspace.c          |  6 ++----
d76c62
 src/util/virmacmap.c             |  8 ++++----
d76c62
 tests/qemublocktest.c            |  3 +--
d76c62
 tests/qemumonitorjsontest.c      |  5 ++---
d76c62
 19 files changed, 35 insertions(+), 76 deletions(-)
d76c62
d76c62
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
d76c62
index 65c38139c4..75e24eb2f6 100644
d76c62
--- a/src/locking/lock_daemon.c
d76c62
+++ b/src/locking/lock_daemon.c
d76c62
@@ -949,8 +949,8 @@ virLockDaemonPreExecRestart(const char *state_file,
d76c62
         goto cleanup;
d76c62
     }
d76c62
 
d76c62
-    if (!(lockspaces = virJSONValueNewArray()))
d76c62
-        goto cleanup;
d76c62
+    lockspaces = virJSONValueNewArray();
d76c62
+
d76c62
     if (virJSONValueObjectAppend(object, "lockspaces", lockspaces) < 0) {
d76c62
         virJSONValueFree(lockspaces);
d76c62
         goto cleanup;
d76c62
diff --git a/src/logging/log_handler.c b/src/logging/log_handler.c
d76c62
index 030c9d66e3..973c52c7cd 100644
d76c62
--- a/src/logging/log_handler.c
d76c62
+++ b/src/logging/log_handler.c
d76c62
@@ -619,8 +619,7 @@ virLogHandlerPreExecRestart(virLogHandlerPtr handler)
d76c62
     if (!ret)
d76c62
         return NULL;
d76c62
 
d76c62
-    if (!(files = virJSONValueNewArray()))
d76c62
-        goto error;
d76c62
+    files = virJSONValueNewArray();
d76c62
 
d76c62
     if (virJSONValueObjectAppend(ret, "files", files) < 0) {
d76c62
         virJSONValueFree(files);
d76c62
diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c
d76c62
index f1a061066e..dd1d5f70ee 100644
d76c62
--- a/src/network/leaseshelper.c
d76c62
+++ b/src/network/leaseshelper.c
d76c62
@@ -200,11 +200,7 @@ main(int argc, char **argv)
d76c62
         break;
d76c62
     }
d76c62
 
d76c62
-    if (!(leases_array_new = virJSONValueNewArray())) {
d76c62
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
d76c62
-                       _("failed to create json"));
d76c62
-        goto cleanup;
d76c62
-    }
d76c62
+    leases_array_new = virJSONValueNewArray();
d76c62
 
d76c62
     if (virLeaseReadCustomLeaseFile(leases_array_new, custom_lease_file,
d76c62
                                     delete ? ip : NULL, &server_duid) < 0)
d76c62
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
d76c62
index 5fa8d24a91..f759785050 100644
d76c62
--- a/src/qemu/qemu_agent.c
d76c62
+++ b/src/qemu/qemu_agent.c
d76c62
@@ -1203,9 +1203,6 @@ qemuAgentMakeStringsArray(const char **strings, unsigned int len)
d76c62
     size_t i;
d76c62
     virJSONValuePtr ret = virJSONValueNewArray(), str;
d76c62
 
d76c62
-    if (!ret)
d76c62
-        return NULL;
d76c62
-
d76c62
     for (i = 0; i < len; i++) {
d76c62
         str = virJSONValueNewString(strings[i]);
d76c62
         if (!str)
d76c62
@@ -1536,8 +1533,7 @@ qemuAgentSetVCPUsCommand(qemuAgentPtr mon,
d76c62
     *nmodified = 0;
d76c62
 
d76c62
     /* create the key data array */
d76c62
-    if (!(cpus = virJSONValueNewArray()))
d76c62
-        goto cleanup;
d76c62
+    cpus = virJSONValueNewArray();
d76c62
 
d76c62
     for (i = 0; i < ninfo; i++) {
d76c62
         qemuAgentCPUInfoPtr in = &info[i];
d76c62
diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c
d76c62
index 8b1e9a7e19..2cc6ff7a42 100644
d76c62
--- a/src/qemu/qemu_backup.c
d76c62
+++ b/src/qemu/qemu_backup.c
d76c62
@@ -180,8 +180,7 @@ qemuBackupDiskPrepareOneBitmapsChain(virDomainMomentDefPtr *incremental,
d76c62
     g_autoptr(virJSONValue) ret = NULL;
d76c62
     size_t incridx = 0;
d76c62
 
d76c62
-    if (!(ret = virJSONValueNewArray()))
d76c62
-        return NULL;
d76c62
+    ret = virJSONValueNewArray();
d76c62
 
d76c62
     if (!(bitmap = qemuBlockNamedNodeDataGetBitmapByName(blockNamedNodeData,
d76c62
                                                          backingChain,
d76c62
@@ -819,8 +818,7 @@ qemuBackupBegin(virDomainObjPtr vm,
d76c62
         !(incremental = qemuBackupBeginCollectIncrementalCheckpoints(vm, def->incremental)))
d76c62
         goto endjob;
d76c62
 
d76c62
-    if (!(actions = virJSONValueNewArray()))
d76c62
-        goto endjob;
d76c62
+    actions = virJSONValueNewArray();
d76c62
 
d76c62
     /* The 'chk' checkpoint must be rolled back if the transaction command
d76c62
      * which creates it on disk is not executed or fails */
d76c62
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
d76c62
index 13e240fdac..03f029368e 100644
d76c62
--- a/src/qemu/qemu_block.c
d76c62
+++ b/src/qemu/qemu_block.c
d76c62
@@ -524,8 +524,7 @@ qemuBlockStorageSourceBuildHostsJSONSocketAddress(virStorageSourcePtr src,
d76c62
     virStorageNetHostDefPtr host;
d76c62
     size_t i;
d76c62
 
d76c62
-    if (!(servers = virJSONValueNewArray()))
d76c62
-        return NULL;
d76c62
+    servers = virJSONValueNewArray();
d76c62
 
d76c62
     for (i = 0; i < src->nhosts; i++) {
d76c62
         host = src->hosts + i;
d76c62
@@ -590,8 +589,7 @@ qemuBlockStorageSourceBuildHostsJSONInetSocketAddress(virStorageSourcePtr src)
d76c62
     virStorageNetHostDefPtr host;
d76c62
     size_t i;
d76c62
 
d76c62
-    if (!(servers = virJSONValueNewArray()))
d76c62
-        return NULL;
d76c62
+    servers = virJSONValueNewArray();
d76c62
 
d76c62
     for (i = 0; i < src->nhosts; i++) {
d76c62
         host = src->hosts + i;
d76c62
@@ -837,8 +835,7 @@ qemuBlockStorageSourceGetRBDProps(virStorageSourcePtr src,
d76c62
         username = srcPriv->secinfo->s.aes.username;
d76c62
         keysecret = srcPriv->secinfo->s.aes.alias;
d76c62
         /* the auth modes are modelled after our old command line generator */
d76c62
-        if (!(authmodes = virJSONValueNewArray()))
d76c62
-            return NULL;
d76c62
+        authmodes = virJSONValueNewArray();
d76c62
 
d76c62
         if (!(mode = virJSONValueNewString("cephx")) ||
d76c62
             virJSONValueArrayAppend(authmodes, mode) < 0)
d76c62
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
d76c62
index e04fcf69d1..3dc9222a6f 100644
d76c62
--- a/src/qemu/qemu_blockjob.c
d76c62
+++ b/src/qemu/qemu_blockjob.c
d76c62
@@ -1344,8 +1344,7 @@ qemuBlockJobProcessEventConcludedBackup(virQEMUDriverPtr driver,
d76c62
         return;
d76c62
 
d76c62
     if (job->data.backup.bitmap) {
d76c62
-        if (!(actions = virJSONValueNewArray()))
d76c62
-            return;
d76c62
+        actions = virJSONValueNewArray();
d76c62
 
d76c62
         if (qemuMonitorTransactionBitmapRemove(actions,
d76c62
                                                job->disk->src->nodeformat,
d76c62
diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c
d76c62
index 59b7f63fdc..c06bfe6a21 100644
d76c62
--- a/src/qemu/qemu_checkpoint.c
d76c62
+++ b/src/qemu/qemu_checkpoint.c
d76c62
@@ -217,8 +217,7 @@ qemuCheckpointDiscardDiskBitmaps(virStorageSourcePtr src,
d76c62
                     return -1;
d76c62
             }
d76c62
 
d76c62
-            if (!(arr = virJSONValueNewArray()))
d76c62
-                return -1;
d76c62
+            arr = virJSONValueNewArray();
d76c62
 
d76c62
             if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(arr,
d76c62
                                                                  n->nodeformat,
d76c62
@@ -261,8 +260,7 @@ qemuCheckpointDiscardBitmaps(virDomainObjPtr vm,
d76c62
     g_autoptr(GSList) relabelimages = NULL;
d76c62
     GSList *next;
d76c62
 
d76c62
-    if (!(actions = virJSONValueNewArray()))
d76c62
-        return -1;
d76c62
+    actions = virJSONValueNewArray();
d76c62
 
d76c62
     qemuDomainObjEnterMonitor(driver, vm);
d76c62
     blockNamedNodeData = qemuMonitorBlockGetNamedNodeData(priv->mon);
d76c62
@@ -535,8 +533,7 @@ qemuCheckpointCreateCommon(virQEMUDriverPtr driver,
d76c62
     if ((parent = virDomainCheckpointGetCurrent(vm->checkpoints)))
d76c62
         (*def)->parent.parent_name = g_strdup(parent->def->name);
d76c62
 
d76c62
-    if (!(tmpactions = virJSONValueNewArray()))
d76c62
-        return -1;
d76c62
+    tmpactions = virJSONValueNewArray();
d76c62
 
d76c62
     if (qemuCheckpointAddActions(vm, tmpactions, parent, *def) < 0)
d76c62
         return -1;
d76c62
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
d76c62
index f7ad2dca28..0667402ebb 100644
d76c62
--- a/src/qemu/qemu_driver.c
d76c62
+++ b/src/qemu/qemu_driver.c
d76c62
@@ -15619,8 +15619,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
d76c62
     if (virDomainObjCheckActive(vm) < 0)
d76c62
         return -1;
d76c62
 
d76c62
-    if (!(actions = virJSONValueNewArray()))
d76c62
-        return -1;
d76c62
+    actions = virJSONValueNewArray();
d76c62
 
d76c62
     if (blockdev &&
d76c62
         !(blockNamedNodeData = qemuBlockGetNamedNodeData(vm, asyncJob)))
d76c62
diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c
d76c62
index 7fb57913e8..68e2c6b40f 100644
d76c62
--- a/src/qemu/qemu_firmware.c
d76c62
+++ b/src/qemu/qemu_firmware.c
d76c62
@@ -651,8 +651,7 @@ qemuFirmwareInterfaceFormat(virJSONValuePtr doc,
d76c62
     g_autoptr(virJSONValue) interfacesJSON = NULL;
d76c62
     size_t i;
d76c62
 
d76c62
-    if (!(interfacesJSON = virJSONValueNewArray()))
d76c62
-        return -1;
d76c62
+    interfacesJSON = virJSONValueNewArray();
d76c62
 
d76c62
     for (i = 0; i < fw->ninterfaces; i++) {
d76c62
         if (virJSONValueArrayAppendString(interfacesJSON,
d76c62
@@ -799,8 +798,7 @@ qemuFirmwareTargetFormat(virJSONValuePtr doc,
d76c62
     g_autoptr(virJSONValue) targetsJSON = NULL;
d76c62
     size_t i;
d76c62
 
d76c62
-    if (!(targetsJSON = virJSONValueNewArray()))
d76c62
-        return -1;
d76c62
+    targetsJSON = virJSONValueNewArray();
d76c62
 
d76c62
     for (i = 0; i < fw->ntargets; i++) {
d76c62
         qemuFirmwareTargetPtr t = fw->targets[i];
d76c62
@@ -816,8 +814,7 @@ qemuFirmwareTargetFormat(virJSONValuePtr doc,
d76c62
                                            virQEMUCapsArchToString(t->architecture)) < 0)
d76c62
             return -1;
d76c62
 
d76c62
-        if (!(machines = virJSONValueNewArray()))
d76c62
-            return -1;
d76c62
+        machines = virJSONValueNewArray();
d76c62
 
d76c62
         for (j = 0; j < t->nmachines; j++) {
d76c62
             if (virJSONValueArrayAppendString(machines,
d76c62
@@ -851,8 +848,7 @@ qemuFirmwareFeatureFormat(virJSONValuePtr doc,
d76c62
     g_autoptr(virJSONValue) featuresJSON = NULL;
d76c62
     size_t i;
d76c62
 
d76c62
-    if (!(featuresJSON = virJSONValueNewArray()))
d76c62
-        return -1;
d76c62
+    featuresJSON = virJSONValueNewArray();
d76c62
 
d76c62
     for (i = 0; i < fw->nfeatures; i++) {
d76c62
         if (virJSONValueArrayAppendString(featuresJSON,
d76c62
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
d76c62
index 9430ce1d00..45acf8cda2 100644
d76c62
--- a/src/qemu/qemu_migration_params.c
d76c62
+++ b/src/qemu/qemu_migration_params.c
d76c62
@@ -785,8 +785,7 @@ qemuMigrationCapsToJSON(virBitmapPtr caps,
d76c62
     qemuMigrationCapability bit;
d76c62
     const char *name;
d76c62
 
d76c62
-    if (!(json = virJSONValueNewArray()))
d76c62
-        return NULL;
d76c62
+    json = virJSONValueNewArray();
d76c62
 
d76c62
     for (bit = 0; bit < QEMU_MIGRATION_CAP_LAST; bit++) {
d76c62
         bool supported = false;
d76c62
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
d76c62
index 3fc0bcb80c..8cd98dbf26 100644
d76c62
--- a/src/qemu/qemu_monitor_json.c
d76c62
+++ b/src/qemu/qemu_monitor_json.c
d76c62
@@ -4802,8 +4802,7 @@ int qemuMonitorJSONSendKey(qemuMonitorPtr mon,
d76c62
     size_t i;
d76c62
 
d76c62
     /* create the key data array */
d76c62
-    if (!(keys = virJSONValueNewArray()))
d76c62
-        goto cleanup;
d76c62
+    keys = virJSONValueNewArray();
d76c62
 
d76c62
     for (i = 0; i < nkeycodes; i++) {
d76c62
         if (keycodes[i] > 0xffff) {
d76c62
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
d76c62
index 4122636805..c87dade1a8 100644
d76c62
--- a/src/rpc/virnetserver.c
d76c62
+++ b/src/rpc/virnetserver.c
d76c62
@@ -603,8 +603,7 @@ virJSONValuePtr virNetServerPreExecRestart(virNetServerPtr srv)
d76c62
         goto error;
d76c62
     }
d76c62
 
d76c62
-    if (!(services = virJSONValueNewArray()))
d76c62
-        goto error;
d76c62
+    services = virJSONValueNewArray();
d76c62
 
d76c62
     if (virJSONValueObjectAppend(object, "services", services) < 0) {
d76c62
         virJSONValueFree(services);
d76c62
@@ -622,8 +621,7 @@ virJSONValuePtr virNetServerPreExecRestart(virNetServerPtr srv)
d76c62
         }
d76c62
     }
d76c62
 
d76c62
-    if (!(clients = virJSONValueNewArray()))
d76c62
-        goto error;
d76c62
+    clients = virJSONValueNewArray();
d76c62
 
d76c62
     if (virJSONValueObjectAppend(object, "clients", clients) < 0) {
d76c62
         virJSONValueFree(clients);
d76c62
diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c
d76c62
index 5d1178f899..0a003e5814 100644
d76c62
--- a/src/rpc/virnetserverservice.c
d76c62
+++ b/src/rpc/virnetserverservice.c
d76c62
@@ -353,8 +353,7 @@ virJSONValuePtr virNetServerServicePreExecRestart(virNetServerServicePtr svc)
d76c62
     if (virJSONValueObjectAppendNumberUint(object, "nrequests_client_max", svc->nrequests_client_max) < 0)
d76c62
         goto error;
d76c62
 
d76c62
-    if (!(socks = virJSONValueNewArray()))
d76c62
-        goto error;
d76c62
+    socks = virJSONValueNewArray();
d76c62
 
d76c62
     if (virJSONValueObjectAppend(object, "socks", socks) < 0) {
d76c62
         virJSONValueFree(socks);
d76c62
diff --git a/src/util/virjson.c b/src/util/virjson.c
d76c62
index 50993648eb..ca57df816f 100644
d76c62
--- a/src/util/virjson.c
d76c62
+++ b/src/util/virjson.c
d76c62
@@ -561,10 +561,7 @@ virJSONValueNewNull(void)
d76c62
 virJSONValuePtr
d76c62
 virJSONValueNewArray(void)
d76c62
 {
d76c62
-    virJSONValuePtr val;
d76c62
-
d76c62
-    if (VIR_ALLOC(val) < 0)
d76c62
-        return NULL;
d76c62
+    virJSONValuePtr val = g_new0(virJSONValue, 1);
d76c62
 
d76c62
     val->type = VIR_JSON_TYPE_ARRAY;
d76c62
 
d76c62
@@ -1265,8 +1262,7 @@ virJSONValueNewArrayFromBitmap(virBitmapPtr bitmap)
d76c62
     virJSONValuePtr ret;
d76c62
     ssize_t pos = -1;
d76c62
 
d76c62
-    if (!(ret = virJSONValueNewArray()))
d76c62
-        return NULL;
d76c62
+    ret = virJSONValueNewArray();
d76c62
 
d76c62
     if (!bitmap)
d76c62
         return ret;
d76c62
@@ -1522,8 +1518,6 @@ virJSONValueCopy(const virJSONValue *in)
d76c62
         break;
d76c62
     case VIR_JSON_TYPE_ARRAY:
d76c62
         out = virJSONValueNewArray();
d76c62
-        if (!out)
d76c62
-            return NULL;
d76c62
         for (i = 0; i < in->data.array.nvalues; i++) {
d76c62
             virJSONValuePtr val = NULL;
d76c62
             if (!(val = virJSONValueCopy(in->data.array.values[i])))
d76c62
@@ -1782,9 +1776,6 @@ virJSONParserHandleStartArray(void *ctx)
d76c62
 
d76c62
     VIR_DEBUG("parser=%p", parser);
d76c62
 
d76c62
-    if (!value)
d76c62
-        return 0;
d76c62
-
d76c62
     if (virJSONParserInsertValue(parser, value) < 0) {
d76c62
         virJSONValueFree(value);
d76c62
         return 0;
d76c62
diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c
d76c62
index 59d47daae8..a44377f89e 100644
d76c62
--- a/src/util/virlockspace.c
d76c62
+++ b/src/util/virlockspace.c
d76c62
@@ -443,8 +443,7 @@ virJSONValuePtr virLockSpacePreExecRestart(virLockSpacePtr lockspace)
d76c62
         virJSONValueObjectAppendString(object, "directory", lockspace->dir) < 0)
d76c62
         goto error;
d76c62
 
d76c62
-    if (!(resources = virJSONValueNewArray()))
d76c62
-        goto error;
d76c62
+    resources = virJSONValueNewArray();
d76c62
 
d76c62
     if (virJSONValueObjectAppend(object, "resources", resources) < 0) {
d76c62
         virJSONValueFree(resources);
d76c62
@@ -479,8 +478,7 @@ virJSONValuePtr virLockSpacePreExecRestart(virLockSpacePtr lockspace)
d76c62
             goto error;
d76c62
         }
d76c62
 
d76c62
-        if (!(owners = virJSONValueNewArray()))
d76c62
-            goto error;
d76c62
+        owners = virJSONValueNewArray();
d76c62
 
d76c62
         if (virJSONValueObjectAppend(child, "owners", owners) < 0) {
d76c62
             virJSONValueFree(owners);
d76c62
diff --git a/src/util/virmacmap.c b/src/util/virmacmap.c
d76c62
index cd74f67678..ec589334ea 100644
d76c62
--- a/src/util/virmacmap.c
d76c62
+++ b/src/util/virmacmap.c
d76c62
@@ -206,10 +206,11 @@ virMACMapHashDumper(void *payload,
d76c62
     size_t i;
d76c62
     int ret = -1;
d76c62
 
d76c62
-    if (!(obj = virJSONValueNewObject()) ||
d76c62
-        !(arr = virJSONValueNewArray()))
d76c62
+    if (!(obj = virJSONValueNewObject()))
d76c62
         goto cleanup;
d76c62
 
d76c62
+    arr = virJSONValueNewArray();
d76c62
+
d76c62
     for (i = 0; macs[i]; i++) {
d76c62
         virJSONValuePtr m = virJSONValueNewString(macs[i]);
d76c62
 
d76c62
@@ -244,8 +245,7 @@ virMacMapDumpStrLocked(virMacMapPtr mgr,
d76c62
     virJSONValuePtr arr;
d76c62
     int ret = -1;
d76c62
 
d76c62
-    if (!(arr = virJSONValueNewArray()))
d76c62
-        goto cleanup;
d76c62
+    arr = virJSONValueNewArray();
d76c62
 
d76c62
     if (virHashForEach(mgr->macs, virMACMapHashDumper, arr) < 0)
d76c62
         goto cleanup;
d76c62
diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
d76c62
index ed8b061e2e..5946cd6c6b 100644
d76c62
--- a/tests/qemublocktest.c
d76c62
+++ b/tests/qemublocktest.c
d76c62
@@ -733,8 +733,7 @@ testQemuCheckpointDeleteMerge(const void *opaque)
d76c62
         return -1;
d76c62
     }
d76c62
 
d76c62
-    if (!(actions = virJSONValueNewArray()))
d76c62
-        return -1;
d76c62
+    actions = virJSONValueNewArray();
d76c62
 
d76c62
     if (qemuCheckpointDiscardDiskBitmaps(data->chain,
d76c62
                                          nodedata,
d76c62
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
d76c62
index 0334f83628..2c696a2e8b 100644
d76c62
--- a/tests/qemumonitorjsontest.c
d76c62
+++ b/tests/qemumonitorjsontest.c
d76c62
@@ -2948,9 +2948,8 @@ testQemuMonitorJSONTransaction(const void *opaque)
d76c62
     if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
d76c62
         return -1;
d76c62
 
d76c62
-    if (!(actions = virJSONValueNewArray()) ||
d76c62
-        !(mergebitmaps = virJSONValueNewArray()))
d76c62
-        return -1;
d76c62
+    actions = virJSONValueNewArray();
d76c62
+    mergebitmaps = virJSONValueNewArray();
d76c62
 
d76c62
     if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(mergebitmaps, "node1", "bitmap1") < 0 ||
d76c62
         qemuMonitorTransactionBitmapMergeSourceAddBitmap(mergebitmaps, "node2", "bitmap2") < 0)
d76c62
-- 
d76c62
2.25.0
d76c62