]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
ch: use g_auto in virCHMonitorBuildMemoryJson
authorWilliam Douglas <william.douglas@intel.com>
Fri, 1 Oct 2021 18:12:35 +0000 (11:12 -0700)
committerLaine Stump <laine@redhat.com>
Tue, 5 Oct 2021 04:07:23 +0000 (00:07 -0400)
Signed-off-by: William Douglas <william.douglas@intel.com>
Reviewed-by: Laine Stump <laine@redhat.com>
src/ch/ch_monitor.c

index 0ceb711f05af986ddc1fbf39ac4c4090a4d0a0f9..841a2b6c8ec2ea993b86eaf7ca3e9432ba881666 100644 (file)
@@ -154,22 +154,19 @@ virCHMonitorBuildKernelRelatedJson(virJSONValue *content, virDomainDef *vmdef)
 static int
 virCHMonitorBuildMemoryJson(virJSONValue *content, virDomainDef *vmdef)
 {
-    virJSONValue *memory;
     unsigned long long total_memory = virDomainDefGetMemoryInitial(vmdef) * 1024;
 
     if (total_memory != 0) {
-        memory = virJSONValueNewObject();
+        g_autoptr(virJSONValue) memory = virJSONValueNewObject();
+
         if (virJSONValueObjectAppendNumberUlong(memory, "size", total_memory) < 0)
-            goto cleanup;
+            return -1;
+
         if (virJSONValueObjectAppend(content, "memory", &memory) < 0)
-            goto cleanup;
+            return -1;
     }
 
     return 0;
-
- cleanup:
-    virJSONValueFree(memory);
-    return -1;
 }
 
 static int