]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
hyperv: use g_autoptr for Msvm_VirtualSystemSettingData in hypervDomainSetAutostart
authorMatt Coleman <mcoleman@datto.com>
Thu, 21 Jan 2021 18:51:15 +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 c63599c09e45c68582c8c10ef3f8b0390249bee3..15770eeba84b06fcc10bba175aa3a172f91fed64 100644 (file)
@@ -2590,47 +2590,41 @@ hypervDomainGetAutostart(virDomainPtr domain, int *autostart)
 static int
 hypervDomainSetAutostart(virDomainPtr domain, int autostart)
 {
-    int result = -1;
     char uuid_string[VIR_UUID_STRING_BUFLEN];
     hypervPrivate *priv = domain->conn->privateData;
-    Msvm_VirtualSystemSettingData *vssd = NULL;
+    g_autoptr(Msvm_VirtualSystemSettingData) vssd = NULL;
     g_autoptr(hypervInvokeParamsList) params = NULL;
     g_autoptr(GHashTable) autostartParam = NULL;
 
     virUUIDFormat(domain->uuid, uuid_string);
 
     if (hypervGetMsvmVirtualSystemSettingDataFromUUID(priv, uuid_string, &vssd) < 0)
-        goto cleanup;
+        return -1;
 
     params = hypervCreateInvokeParamsList("ModifySystemSettings",
                                           MSVM_VIRTUALSYSTEMMANAGEMENTSERVICE_SELECTOR,
                                           Msvm_VirtualSystemManagementService_WmiInfo);
 
     if (!params)
-        goto cleanup;
+        return -1;
 
     autostartParam = hypervCreateEmbeddedParam(Msvm_VirtualSystemSettingData_WmiInfo);
 
     if (hypervSetEmbeddedProperty(autostartParam, "AutomaticStartupAction",
                                   autostart ? "4" : "2") < 0)
-        goto cleanup;
+        return -1;
 
     if (hypervSetEmbeddedProperty(autostartParam, "InstanceID", vssd->data->InstanceID) < 0)
-        goto cleanup;
+        return -1;
 
     if (hypervAddEmbeddedParam(params, "SystemSettings",
                                &autostartParam, Msvm_VirtualSystemSettingData_WmiInfo) < 0)
-        goto cleanup;
+        return -1;
 
     if (hypervInvokeMethod(priv, &params, NULL) < 0)
-        goto cleanup;
-
-    result = 0;
-
- cleanup:
-    hypervFreeObject((hypervObject *)vssd);
+        return -1;
 
-    return result;
+    return 0;
 }