[PATCH 27/55] hyperv: use g_autoptr for WMI classes in hypervDomainGetInfo

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

 



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

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 40e4c97d35..9cf074b6a7 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -1913,13 +1913,12 @@ hypervDomainSetMemory(virDomainPtr domain, unsigned long memory)
 static int
 hypervDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
 {
-    int result = -1;
     hypervPrivate *priv = domain->conn->privateData;
     char uuid_string[VIR_UUID_STRING_BUFLEN];
-    Msvm_ComputerSystem *computerSystem = NULL;
-    Msvm_VirtualSystemSettingData *virtualSystemSettingData = NULL;
-    Msvm_ProcessorSettingData *processorSettingData = NULL;
-    Msvm_MemorySettingData *memorySettingData = NULL;
+    g_autoptr(Msvm_ComputerSystem) computerSystem = NULL;
+    g_autoptr(Msvm_VirtualSystemSettingData) virtualSystemSettingData = NULL;
+    g_autoptr(Msvm_ProcessorSettingData) processorSettingData = NULL;
+    g_autoptr(Msvm_MemorySettingData) memorySettingData = NULL;
 
     memset(info, 0, sizeof(*info));
 
@@ -1927,21 +1926,21 @@ hypervDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
 
     /* Get Msvm_ComputerSystem */
     if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
-        goto cleanup;
+        return -1;
 
     if (hypervGetMsvmVirtualSystemSettingDataFromUUID(priv, uuid_string,
                                                       &virtualSystemSettingData) < 0)
-        goto cleanup;
+        return -1;
 
     if (hypervGetProcessorSD(priv,
                              virtualSystemSettingData->data->InstanceID,
                              &processorSettingData) < 0)
-        goto cleanup;
+        return -1;
 
     if (hypervGetMemorySD(priv,
                           virtualSystemSettingData->data->InstanceID,
                           &memorySettingData) < 0)
-        goto cleanup;
+        return -1;
 
     /* Fill struct */
     info->state = hypervMsvmComputerSystemEnabledStateToDomainState(computerSystem);
@@ -1950,15 +1949,7 @@ hypervDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
     info->nrVirtCpu = processorSettingData->data->VirtualQuantity;
     info->cpuTime = 0;
 
-    result = 0;
-
- cleanup:
-    hypervFreeObject((hypervObject *)computerSystem);
-    hypervFreeObject((hypervObject *)virtualSystemSettingData);
-    hypervFreeObject((hypervObject *)processorSettingData);
-    hypervFreeObject((hypervObject *)memorySettingData);
-
-    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