ch: use g_auto in virCHMonitorBuildVMJson

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
Ján Tomko 2021-09-22 22:50:48 +02:00
parent b4436cc3f5
commit 4a6d874946

View File

@ -365,41 +365,36 @@ virCHMonitorBuildNetsJson(virJSONValue *content, virDomainDef *vmdef)
static int static int
virCHMonitorBuildVMJson(virDomainDef *vmdef, char **jsonstr) virCHMonitorBuildVMJson(virDomainDef *vmdef, char **jsonstr)
{ {
virJSONValue *content = virJSONValueNewObject(); g_autoptr(virJSONValue) content = virJSONValueNewObject();
int ret = -1;
if (vmdef == NULL) { if (vmdef == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("VM is not defined")); _("VM is not defined"));
goto cleanup; return -1;
} }
if (virCHMonitorBuildPTYJson(content, vmdef) < 0) if (virCHMonitorBuildPTYJson(content, vmdef) < 0)
goto cleanup; return -1;
if (virCHMonitorBuildCPUJson(content, vmdef) < 0) if (virCHMonitorBuildCPUJson(content, vmdef) < 0)
goto cleanup; return -1;
if (virCHMonitorBuildMemoryJson(content, vmdef) < 0) if (virCHMonitorBuildMemoryJson(content, vmdef) < 0)
goto cleanup; return -1;
if (virCHMonitorBuildKernelRelatedJson(content, vmdef) < 0) if (virCHMonitorBuildKernelRelatedJson(content, vmdef) < 0)
goto cleanup; return -1;
if (virCHMonitorBuildDisksJson(content, vmdef) < 0) if (virCHMonitorBuildDisksJson(content, vmdef) < 0)
goto cleanup; return -1;
if (virCHMonitorBuildNetsJson(content, vmdef) < 0) if (virCHMonitorBuildNetsJson(content, vmdef) < 0)
goto cleanup; return -1;
if (!(*jsonstr = virJSONValueToString(content, false))) if (!(*jsonstr = virJSONValueToString(content, false)))
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
virJSONValueFree(content);
return ret;
} }
static int static int