]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
hyperv: use g_autoptr for Msvm_ComputerSystem in hypervRequestStateChange
authorMatt Coleman <mcoleman@datto.com>
Thu, 21 Jan 2021 18:51:02 +0000 (13:51 -0500)
committerLaine Stump <laine@redhat.com>
Fri, 22 Jan 2021 19:04:26 +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 f3fe88926e26ae1d4a07eaa396b70a54c255ab53..ef3ae54f7df163334f8f17270024f5911aec0bd8 100644 (file)
@@ -197,23 +197,17 @@ hypervGetOperatingSystem(hypervPrivate *priv, Win32_OperatingSystem **operatingS
 static int
 hypervRequestStateChange(virDomainPtr domain, int state)
 {
-    int result = -1;
-    Msvm_ComputerSystem *computerSystem = NULL;
+    g_autoptr(Msvm_ComputerSystem) computerSystem = NULL;
 
     if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
-        goto cleanup;
+        return -1;
 
     if (computerSystem->data->EnabledState != MSVM_COMPUTERSYSTEM_ENABLEDSTATE_ENABLED) {
         virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not active"));
-        goto cleanup;
+        return -1;
     }
 
-    result = hypervInvokeMsvmComputerSystemRequestStateChange(domain, state);
-
- cleanup:
-    hypervFreeObject((hypervObject *)computerSystem);
-
-    return result;
+    return hypervInvokeMsvmComputerSystemRequestStateChange(domain, state);
 }