[PATCH 16/55] hyperv: use g_autoptr for Msvm_ComputerSystem in hypervDomainLookupByName

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


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

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index fe1ab1c52c..dd5c42c45b 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -1689,23 +1689,20 @@ hypervDomainLookupByName(virConnectPtr conn, const char *name)
 {
     virDomainPtr domain = NULL;
     hypervPrivate *priv = conn->privateData;
-    Msvm_ComputerSystem *computerSystem = NULL;
+    g_autoptr(Msvm_ComputerSystem) computerSystem = NULL;
 
     if (hypervGetVirtualSystemByName(priv, name, &computerSystem) < 0)
-        goto cleanup;
+        return NULL;
 
     if (computerSystem->next) {
         virReportError(VIR_ERR_MULTIPLE_DOMAINS,
                        _("Multiple domains exist with the name '%s': repeat the request using a UUID"),
                        name);
-        goto cleanup;
+        return NULL;
     }
 
     hypervMsvmComputerSystemToDomain(conn, computerSystem, &domain);
 
- cleanup:
-    hypervFreeObject((hypervObject *)computerSystem);
-
     return domain;
 }
 
-- 
2.30.0





More information about the libvir-list mailing list