]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
hyperv: use g_autoptr for Msvm_ComputerSystem in hypervConnectNumOfDomains
authorMatt Coleman <mcoleman@datto.com>
Thu, 21 Jan 2021 18:50:52 +0000 (13:50 -0500)
committerLaine Stump <laine@redhat.com>
Fri, 22 Jan 2021 19:04:25 +0000 (14:04 -0500)
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
src/hyperv/hyperv_driver.c

index e2773d0d2f57fe67af63a3cab563336a7a245218..efafe9ece2acd65914ede3231980ddbefda6b048 100644 (file)
@@ -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;
 }