render / rpms / libvirt

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