[PATCH 29/55] hyperv: use g_autoptr for WMI classes in hypervDomainSetVcpusFlags

Matt Coleman mcoleman at datto.com
Thu Jan 21 18:51:09 UTC 2021


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

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 44be9fbd2f..f056761338 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -1978,11 +1978,10 @@ hypervDomainSetVcpusFlags(virDomainPtr domain,
                           unsigned int nvcpus,
                           unsigned int flags)
 {
-    int result = -1;
     char uuid_string[VIR_UUID_STRING_BUFLEN];
     hypervPrivate *priv = domain->conn->privateData;
-    Msvm_VirtualSystemSettingData *vssd = NULL;
-    Msvm_ProcessorSettingData *proc_sd = NULL;
+    g_autoptr(Msvm_VirtualSystemSettingData) vssd = NULL;
+    g_autoptr(Msvm_ProcessorSettingData) proc_sd = NULL;
     g_autoptr(GHashTable) vcpuResource = NULL;
     g_autofree char *nvcpus_str = g_strdup_printf("%u", nvcpus);
 
@@ -1991,32 +1990,26 @@ hypervDomainSetVcpusFlags(virDomainPtr domain,
     virUUIDFormat(domain->uuid, uuid_string);
 
     if (hypervGetMsvmVirtualSystemSettingDataFromUUID(priv, uuid_string, &vssd) < 0)
-        goto cleanup;
+        return -1;
 
     if (hypervGetProcessorSD(priv, vssd->data->InstanceID, &proc_sd) < 0)
-        goto cleanup;
+        return -1;
 
     vcpuResource = hypervCreateEmbeddedParam(Msvm_ProcessorSettingData_WmiInfo);
     if (!vcpuResource)
-        goto cleanup;
+        return -1;
 
     if (hypervSetEmbeddedProperty(vcpuResource, "VirtualQuantity", nvcpus_str) < 0)
-        goto cleanup;
+        return -1;
 
     if (hypervSetEmbeddedProperty(vcpuResource, "InstanceID", proc_sd->data->InstanceID) < 0)
-        goto cleanup;
+        return -1;
 
     if (hypervMsvmVSMSModifyResourceSettings(priv, &vcpuResource,
                                              Msvm_ProcessorSettingData_WmiInfo) < 0)
-        goto cleanup;
-
-    result = 0;
-
- cleanup:
-    hypervFreeObject((hypervObject *)vssd);
-    hypervFreeObject((hypervObject *)proc_sd);
+        return -1;
 
-    return result;
+    return 0;
 }
 
 
-- 
2.30.0





More information about the libvir-list mailing list