[PATCH 12/55] hyperv: use g_autoptr for Msvm_ComputerSystem in hypervConnectNumOfDomains

Matt Coleman mcoleman at datto.com
Thu Jan 21 18:50:52 UTC 2021


Signed-off-by: Matt Coleman <matt at datto.com>
---
 src/hyperv/hyperv_driver.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

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;
 }
 
 
-- 
2.30.0





More information about the libvir-list mailing list