[PATCH 11/55] hyperv: use g_autoptr for WMI classes in hypervNodeGetInfo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Matt Coleman <matt@xxxxxxxxx>
---
 src/hyperv/hyperv_driver.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 6375f6b011..e2773d0d2f 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -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;
 }
 
 
-- 
2.30.0





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux