]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
ch: use g_auto in virCHMonitorBuildVMJson
authorJán Tomko <jtomko@redhat.com>
Wed, 22 Sep 2021 20:50:48 +0000 (22:50 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 23 Sep 2021 13:32:01 +0000 (15:32 +0200)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
src/ch/ch_monitor.c

index 6a1b62b4a2e8a80e3259836199e0539d60fc61e7..5ed26a574fc4b6e3846ac314dcb3c68ca8daf6a9 100644 (file)
@@ -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