From: Ján Tomko Date: Wed, 22 Sep 2021 20:50:48 +0000 (+0200) Subject: ch: use g_auto in virCHMonitorBuildVMJson X-Git-Tag: v7.8.0-rc1~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a6d8749464f7df60dab0ec44902533040b6d718;p=thirdparty%2Flibvirt.git ch: use g_auto in virCHMonitorBuildVMJson Signed-off-by: Ján Tomko Reviewed-by: Laine Stump --- diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 6a1b62b4a2..5ed26a574f 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -365,41 +365,36 @@ virCHMonitorBuildNetsJson(virJSONValue *content, virDomainDef *vmdef) static int virCHMonitorBuildVMJson(virDomainDef *vmdef, char **jsonstr) { - virJSONValue *content = virJSONValueNewObject(); - int ret = -1; + g_autoptr(virJSONValue) content = virJSONValueNewObject(); if (vmdef == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("VM is not defined")); - goto cleanup; + return -1; } if (virCHMonitorBuildPTYJson(content, vmdef) < 0) - goto cleanup; + return -1; if (virCHMonitorBuildCPUJson(content, vmdef) < 0) - goto cleanup; + return -1; if (virCHMonitorBuildMemoryJson(content, vmdef) < 0) - goto cleanup; + return -1; if (virCHMonitorBuildKernelRelatedJson(content, vmdef) < 0) - goto cleanup; + return -1; if (virCHMonitorBuildDisksJson(content, vmdef) < 0) - goto cleanup; + return -1; if (virCHMonitorBuildNetsJson(content, vmdef) < 0) - goto cleanup; + return -1; if (!(*jsonstr = virJSONValueToString(content, false))) - goto cleanup; - - ret = 0; + return -1; - cleanup: - virJSONValueFree(content); - return ret; + return 0; } static int