From: Matt Coleman Date: Thu, 21 Jan 2021 18:50:49 +0000 (-0500) Subject: hyperv: use g_autoptr for Win32_ComputerSystem in hypervConnectGetHostname X-Git-Tag: v7.1.0-rc1~492 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=067168bf6934887587089892f3d96dacfdf3d9d4;p=thirdparty%2Flibvirt.git hyperv: use g_autoptr for Win32_ComputerSystem in hypervConnectGetHostname Signed-off-by: Matt Coleman Reviewed-by: Laine Stump --- 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); }