[PATCH 09/55] hyperv: use g_autoptr for Win32_ComputerSystem in hypervConnectGetHostname

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

 



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

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 830a3414c5..8b59dd05f7 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -1493,19 +1493,12 @@ hypervConnectGetVersion(virConnectPtr conn, unsigned long *version)
 static char *
 hypervConnectGetHostname(virConnectPtr conn)
 {
-    char *hostname = NULL;
-    hypervPrivate *priv = conn->privateData;
-    Win32_ComputerSystem *computerSystem = NULL;
-
-    if (hypervGetPhysicalSystemList(priv, &computerSystem) < 0)
-        goto cleanup;
-
-    hostname = g_strdup(computerSystem->data->DNSHostName);
+    g_autoptr(Win32_ComputerSystem) computerSystem = NULL;
 
- cleanup:
-    hypervFreeObject((hypervObject *)computerSystem);
+    if (hypervGetPhysicalSystemList((hypervPrivate *)conn->privateData, &computerSystem) < 0)
+        return NULL;
 
-    return hostname;
+    return g_strdup(computerSystem->data->DNSHostName);
 }
 
 
-- 
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