Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
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);
}