hyperv: use g_autoptr for Win32_ComputerSystem in hypervConnectGetHostname

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
Matt Coleman 2021-01-21 13:50:49 -05:00 committed by Laine Stump
parent 1c603b7c02
commit 067168bf69

View File

@ -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;
g_autoptr(Win32_ComputerSystem) computerSystem = NULL;
if (hypervGetPhysicalSystemList(priv, &computerSystem) < 0)
goto cleanup;
if (hypervGetPhysicalSystemList((hypervPrivate *)conn->privateData, &computerSystem) < 0)
return NULL;
hostname = g_strdup(computerSystem->data->DNSHostName);
cleanup:
hypervFreeObject((hypervObject *)computerSystem);
return hostname;
return g_strdup(computerSystem->data->DNSHostName);
}