qemu_command: use VIR_AUTOPTR for virJSONValue

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Ján Tomko 2019-08-20 12:39:39 +02:00
parent efef46dd48
commit 28ad2bcf39

View File

@ -738,7 +738,7 @@ qemuBuildObjectSecretCommandLine(virCommandPtr cmd,
{
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
int ret = -1;
virJSONValuePtr props = NULL;
VIR_AUTOPTR(virJSONValue) props = NULL;
if (qemuBuildSecretInfoProps(secinfo, &props) < 0)
return -1;
@ -752,7 +752,6 @@ qemuBuildObjectSecretCommandLine(virCommandPtr cmd,
ret = 0;
cleanup:
virJSONValueFree(props);
return ret;
}
@ -935,7 +934,7 @@ qemuBuildTLSx509CommandLine(virCommandPtr cmd,
{
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
int ret = -1;
virJSONValuePtr props = NULL;
VIR_AUTOPTR(virJSONValue) props = NULL;
if (qemuBuildTLSx509BackendProps(tlspath, isListen, verifypeer, alias,
certEncSecretAlias, qemuCaps, &props) < 0)
@ -950,7 +949,6 @@ qemuBuildTLSx509CommandLine(virCommandPtr cmd,
ret = 0;
cleanup:
virJSONValueFree(props);
return ret;
}
@ -1595,16 +1593,14 @@ qemuDiskSourceNeedsProps(virStorageSourcePtr src,
static virJSONValuePtr
qemuDiskSourceGetProps(virStorageSourcePtr src)
{
virJSONValuePtr props;
VIR_AUTOPTR(virJSONValue) props = NULL;
virJSONValuePtr ret;
if (!(props = qemuBlockStorageSourceGetBackendProps(src, true, false, false)))
return NULL;
if (virJSONValueObjectCreate(&ret, "a:file", &props, NULL) < 0) {
virJSONValueFree(props);
if (virJSONValueObjectCreate(&ret, "a:file", &props, NULL) < 0)
return NULL;
}
return ret;
}
@ -1641,7 +1637,7 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
qemuDomainStorageSourcePrivatePtr srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
qemuDomainSecretInfoPtr secinfo = NULL;
qemuDomainSecretInfoPtr encinfo = NULL;
virJSONValuePtr srcprops = NULL;
VIR_AUTOPTR(virJSONValue) srcprops = NULL;
char *source = NULL;
bool rawluks = false;
int ret = -1;
@ -1729,7 +1725,6 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
cleanup:
VIR_FREE(source);
virJSONValueFree(srcprops);
return ret;
}
@ -3407,7 +3402,7 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
bool prealloc = false;
virBitmapPtr nodemask = NULL;
int ret = -1;
virJSONValuePtr props = NULL;
VIR_AUTOPTR(virJSONValue) props = NULL;
bool nodeSpecified = virDomainNumatuneNodeSpecified(def->numa, mem->targetNode);
unsigned long long pagesize = mem->pagesize;
bool needHugepage = !!pagesize;
@ -3651,7 +3646,6 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
ret = -1;
cleanup:
virJSONValueFree(props);
VIR_FREE(memPath);
return ret;
}
@ -3664,7 +3658,7 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def,
qemuDomainObjPrivatePtr priv,
virBufferPtr buf)
{
virJSONValuePtr props = NULL;
VIR_AUTOPTR(virJSONValue) props = NULL;
char *alias = NULL;
int ret = -1;
int rc;
@ -3690,7 +3684,6 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def,
cleanup:
VIR_FREE(alias);
virJSONValueFree(props);
return ret;
}
@ -3703,7 +3696,7 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf,
virQEMUDriverConfigPtr cfg,
qemuDomainObjPrivatePtr priv)
{
virJSONValuePtr props = NULL;
VIR_AUTOPTR(virJSONValue) props = NULL;
char *alias = NULL;
int ret = -1;
@ -3727,7 +3720,6 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf,
cleanup:
VIR_FREE(alias);
virJSONValueFree(props);
return ret;
}
@ -5022,7 +5014,7 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
char *ret = NULL;
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
char *netsource = NULL;
virJSONValuePtr srcprops = NULL;
VIR_AUTOPTR(virJSONValue) srcprops = NULL;
virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
qemuDomainStorageSourcePrivatePtr srcPriv =
@ -5051,7 +5043,6 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
cleanup:
VIR_FREE(netsource);
virJSONValueFree(srcprops);
return ret;
}
@ -6036,7 +6027,7 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager,
size_t i;
for (i = 0; i < def->nrngs; i++) {
virJSONValuePtr props;
VIR_AUTOPTR(virJSONValue) props = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
virDomainRNGDefPtr rng = def->rngs[i];
char *tmp;
@ -6063,7 +6054,6 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager,
return -1;
rc = virQEMUBuildObjectCommandlineFromJSON(&buf, props);
virJSONValueFree(props);
if (rc < 0)
return -1;
@ -9225,7 +9215,7 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
virQEMUCapsPtr qemuCaps,
bool chardevStdioLogd)
{
virJSONValuePtr memProps = NULL;
VIR_AUTOPTR(virJSONValue) memProps = NULL;
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
char *devstr = NULL;
int rc;
@ -9270,7 +9260,6 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
return -1;
rc = virQEMUBuildObjectCommandlineFromJSON(&buf, memProps);
virJSONValueFree(memProps);
if (rc < 0)
return -1;
@ -10247,7 +10236,7 @@ qemuBuildManagedPRCommandLine(virCommandPtr cmd,
qemuDomainObjPrivatePtr priv)
{
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
virJSONValuePtr props = NULL;
VIR_AUTOPTR(virJSONValue) props = NULL;
int ret = -1;
if (!virDomainDefHasManagedPR(def))
@ -10264,7 +10253,6 @@ qemuBuildManagedPRCommandLine(virCommandPtr cmd,
ret = 0;
cleanup:
virJSONValueFree(props);
return ret;
}