]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
hyperv: use g_autoptr for Msvm_ComputerSystem in hypervDomainManagedSaveRemove
authorMatt Coleman <mcoleman@datto.com>
Thu, 21 Jan 2021 18:51:20 +0000 (13:51 -0500)
committerLaine Stump <laine@redhat.com>
Fri, 22 Jan 2021 19:04:28 +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 d4852d55af77055425dc72400d72088d4ddb65b8..f134b7f137c337b05ed60ee9fbabcf19e7a6c120 100644 (file)
@@ -2843,27 +2843,21 @@ hypervDomainHasManagedSaveImage(virDomainPtr domain, unsigned int flags)
 static int
 hypervDomainManagedSaveRemove(virDomainPtr domain, unsigned int flags)
 {
-    int result = -1;
-    Msvm_ComputerSystem *computerSystem = NULL;
+    g_autoptr(Msvm_ComputerSystem) computerSystem = NULL;
 
     virCheckFlags(0, -1);
 
     if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
-        goto cleanup;
+        return -1;
 
     if (computerSystem->data->EnabledState != MSVM_COMPUTERSYSTEM_ENABLEDSTATE_SUSPENDED) {
         virReportError(VIR_ERR_OPERATION_INVALID, "%s",
                        _("Domain has no managed save image"));
-        goto cleanup;
+        return -1;
     }
 
-    result = hypervInvokeMsvmComputerSystemRequestStateChange(domain,
-                                                              MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_DISABLED);
-
- cleanup:
-    hypervFreeObject((hypervObject *)computerSystem);
-
-    return result;
+    return hypervInvokeMsvmComputerSystemRequestStateChange(domain,
+                                                            MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_DISABLED);
 }