Signed-off-by: Matt Coleman <matt(a)datto.com>
---
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