From: Matt Coleman Date: Thu, 21 Jan 2021 18:50:52 +0000 (-0500) Subject: hyperv: use g_autoptr for Msvm_ComputerSystem in hypervConnectNumOfDomains X-Git-Tag: v7.1.0-rc1~489 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1274d4e9f6f28c496e22c0e54804645a7e710ac2;p=thirdparty%2Flibvirt.git hyperv: use g_autoptr for Msvm_ComputerSystem in hypervConnectNumOfDomains Signed-off-by: Matt Coleman Reviewed-by: Laine Stump --- diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index e2773d0d2f..efafe9ece2 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -1638,26 +1638,20 @@ hypervConnectListDomains(virConnectPtr conn, int *ids, int maxids) static int hypervConnectNumOfDomains(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 (hypervGetActiveVirtualSystemList(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; }