]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
hyperv: use g_autoptr for WMI classes in hypervNodeGetInfo
authorMatt Coleman <mcoleman@datto.com>
Thu, 21 Jan 2021 18:50:51 +0000 (13:50 -0500)
committerLaine Stump <laine@redhat.com>
Fri, 22 Jan 2021 19:04:25 +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 6375f6b011772157eb49c4d2bc4ae34cd9d351b0..e2773d0d2f57fe67af63a3cab563336a7a245218 100644 (file)
@@ -1540,20 +1540,19 @@ hypervConnectGetMaxVcpus(virConnectPtr conn, const char *type G_GNUC_UNUSED)
 static int
 hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info)
 {
-    int result = -1;
     hypervPrivate *priv = conn->privateData;
-    Win32_ComputerSystem *computerSystem = NULL;
-    Win32_Processor *processorList = NULL;
+    g_autoptr(Win32_ComputerSystem) computerSystem = NULL;
+    g_autoptr(Win32_Processor) processorList = NULL;
     Win32_Processor *processor = NULL;
     char *tmp;
 
     memset(info, 0, sizeof(*info));
 
     if (hypervGetPhysicalSystemList(priv, &computerSystem) < 0)
-        goto cleanup;
+        return -1;
 
     if (hypervGetProcessorsByName(priv, computerSystem->data->Name, &processorList) < 0) {
-        goto cleanup;
+        return -1;
     }
 
     /* Strip the string to fit more relevant information in 32 chars */
@@ -1583,7 +1582,7 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info)
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("CPU model %s too long for destination"),
                        processorList->data->Name);
-        goto cleanup;
+        return -1;
     }
 
     info->memory = computerSystem->data->TotalPhysicalMemory / 1024; /* byte to kilobyte */
@@ -1600,13 +1599,7 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info)
     info->threads = processorList->data->NumberOfLogicalProcessors / info->cores;
     info->cpus = info->sockets * info->cores;
 
-    result = 0;
-
- cleanup:
-    hypervFreeObject((hypervObject *)computerSystem);
-    hypervFreeObject((hypervObject *)processorList);
-
-    return result;
+    return 0;
 }