]> xenbits.xensource.com Git - libvirt.git/commitdiff
hyperv: use g_autoptr for WMI classes in hypervDomainGetMaxMemory
authorMatt Coleman <mcoleman@datto.com>
Thu, 21 Jan 2021 18:51:00 +0000 (13:51 -0500)
committerLaine Stump <laine@redhat.com>
Fri, 22 Jan 2021 19:04:26 +0000 (14:04 -0500)
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
src/hyperv/hyperv_driver.c

index 7da4c216b17213cbf593420e2e6f5fcd28480910..2ec0415f621aa8e357d48e201a0c1673ff4240ca 100644 (file)
@@ -1860,25 +1860,18 @@ hypervDomainGetMaxMemory(virDomainPtr domain)
 {
     char uuid_string[VIR_UUID_STRING_BUFLEN];
     hypervPrivate *priv = domain->conn->privateData;
-    Msvm_VirtualSystemSettingData *vssd = NULL;
-    Msvm_MemorySettingData *mem_sd = NULL;
-    int maxMemoryBytes = 0;
+    g_autoptr(Msvm_VirtualSystemSettingData) vssd = NULL;
+    g_autoptr(Msvm_MemorySettingData) mem_sd = NULL;
 
     virUUIDFormat(domain->uuid, uuid_string);
 
     if (hypervGetMsvmVirtualSystemSettingDataFromUUID(priv, uuid_string, &vssd) < 0)
-        goto cleanup;
+        return 0;
 
     if (hypervGetMemorySD(priv, vssd->data->InstanceID, &mem_sd) < 0)
-        goto cleanup;
-
-    maxMemoryBytes = mem_sd->data->Limit * 1024;
-
- cleanup:
-    hypervFreeObject((hypervObject *)vssd);
-    hypervFreeObject((hypervObject *)mem_sd);
+        return 0;
 
-    return maxMemoryBytes;
+    return mem_sd->data->Limit * 1024;
 }