From f7c167a76e9baa3869aea141e9c78f7631a23d44 Mon Sep 17 00:00:00 2001 From: Matt Coleman Date: Thu, 21 Jan 2021 13:51:01 -0500 Subject: [PATCH] hyperv: use g_autoptr for WMI classes in hypervDomainSetMemoryProperty Signed-off-by: Matt Coleman Reviewed-by: Laine Stump --- 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 2ec0415f62..f3fe88926e 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -1880,43 +1880,36 @@ hypervDomainSetMemoryProperty(virDomainPtr domain, unsigned long memory, const char* propertyName) { - int result = -1; char uuid_string[VIR_UUID_STRING_BUFLEN]; hypervPrivate *priv = domain->conn->privateData; - Msvm_VirtualSystemSettingData *vssd = NULL; - Msvm_MemorySettingData *memsd = NULL; + g_autoptr(Msvm_VirtualSystemSettingData) vssd = NULL; + g_autoptr(Msvm_MemorySettingData) memsd = NULL; g_autoptr(GHashTable) memResource = NULL; g_autofree char *memory_str = g_strdup_printf("%lu", VIR_ROUND_UP(VIR_DIV_UP(memory, 1024), 2)); virUUIDFormat(domain->uuid, uuid_string); if (hypervGetMsvmVirtualSystemSettingDataFromUUID(priv, uuid_string, &vssd) < 0) - goto cleanup; + return -1; if (hypervGetMemorySD(priv, vssd->data->InstanceID, &memsd) < 0) - goto cleanup; + return -1; memResource = hypervCreateEmbeddedParam(Msvm_MemorySettingData_WmiInfo); if (!memResource) - goto cleanup; + return -1; if (hypervSetEmbeddedProperty(memResource, propertyName, memory_str) < 0) - goto cleanup; + return -1; if (hypervSetEmbeddedProperty(memResource, "InstanceID", memsd->data->InstanceID) < 0) - goto cleanup; + return -1; if (hypervMsvmVSMSModifyResourceSettings(priv, &memResource, Msvm_MemorySettingData_WmiInfo) < 0) - goto cleanup; + return -1; - result = 0; - - cleanup: - hypervFreeObject((hypervObject *)vssd); - hypervFreeObject((hypervObject *)memsd); - - return result; + return 0; }