From: Matt Coleman Date: Thu, 21 Jan 2021 18:51:12 +0000 (-0500) Subject: hyperv: use g_autoptr for Msvm_ComputerSystem in hypervConnectNumOfDefinedDomains X-Git-Tag: v7.1.0-rc1~469 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a0c80ab23165816a63c5fa182e6d7649be0ecbd;p=thirdparty%2Flibvirt.git hyperv: use g_autoptr for Msvm_ComputerSystem in hypervConnectNumOfDefinedDomains Signed-off-by: Matt Coleman Reviewed-by: Laine Stump --- diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index f1e6efd343..a73b463260 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -2291,26 +2291,20 @@ hypervConnectListDefinedDomains(virConnectPtr conn, char **const names, int maxn static int hypervConnectNumOfDefinedDomains(virConnectPtr conn) { - bool success = false; hypervPrivate *priv = conn->privateData; - Msvm_ComputerSystem *computerSystemList = NULL; + g_autoptr(Msvm_ComputerSystem) computerSystemList = NULL; Msvm_ComputerSystem *computerSystem = NULL; int count = 0; if (hypervGetInactiveVirtualSystemList(priv, &computerSystemList) < 0) - goto cleanup; + return -1; for (computerSystem = computerSystemList; computerSystem != NULL; computerSystem = computerSystem->next) { ++count; } - success = true; - - cleanup: - hypervFreeObject((hypervObject *)computerSystemList); - - return success ? count : -1; + return count; }