]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
hyperv: use g_autoptr for Msvm_ComputerSystem in hypervDomainManagedSave
authorMatt Coleman <mcoleman@datto.com>
Thu, 21 Jan 2021 18:51:18 +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 e501a88889babfa3012ab9aaf2bc00e08d0c4721..476c24533d6be9ff1ed8b4a34f414f907fdf38d3 100644 (file)
@@ -2807,28 +2807,22 @@ hypervDomainIsUpdated(virDomainPtr domain G_GNUC_UNUSED)
 static int
 hypervDomainManagedSave(virDomainPtr domain, unsigned int flags)
 {
-    int result = -1;
-    Msvm_ComputerSystem *computerSystem = NULL;
+    g_autoptr(Msvm_ComputerSystem) computerSystem = NULL;
     bool in_transition = false;
 
     virCheckFlags(0, -1);
 
     if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
-        goto cleanup;
+        return -1;
 
     if (!hypervIsMsvmComputerSystemActive(computerSystem, &in_transition) ||
         in_transition) {
         virReportError(VIR_ERR_OPERATION_INVALID, "%s",
                        _("Domain is not active or is in state transition"));
-        goto cleanup;
+        return -1;
     }
 
-    result = hypervInvokeMsvmComputerSystemRequestStateChange(domain, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_OFFLINE);
-
- cleanup:
-    hypervFreeObject((hypervObject *)computerSystem);
-
-    return result;
+    return hypervInvokeMsvmComputerSystemRequestStateChange(domain, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_OFFLINE);
 }