]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
hyperv: use g_autoptr for Msvm_ComputerSystem in hypervConnectNumOfDefinedDomains
authorMatt Coleman <mcoleman@datto.com>
Thu, 21 Jan 2021 18:51:12 +0000 (13:51 -0500)
committerLaine Stump <laine@redhat.com>
Fri, 22 Jan 2021 19:04:27 +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 f1e6efd343027323db9039e4ef9a1d96320e9a84..a73b46326020517ced669c703b761ba1d278c842 100644 (file)
@@ -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;
 }