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