From: Matt Coleman Date: Thu, 21 Jan 2021 18:51:00 +0000 (-0500) Subject: hyperv: use g_autoptr for WMI classes in hypervDomainGetMaxMemory X-Git-Tag: v7.1.0-rc1~481 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25faf51e010e17f382920ebe291f61cdf1bfb865;p=thirdparty%2Flibvirt.git hyperv: use g_autoptr for WMI classes in hypervDomainGetMaxMemory Signed-off-by: Matt Coleman Reviewed-by: Laine Stump --- diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 7da4c216b1..2ec0415f62 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -1860,25 +1860,18 @@ hypervDomainGetMaxMemory(virDomainPtr domain) { char uuid_string[VIR_UUID_STRING_BUFLEN]; hypervPrivate *priv = domain->conn->privateData; - Msvm_VirtualSystemSettingData *vssd = NULL; - Msvm_MemorySettingData *mem_sd = NULL; - int maxMemoryBytes = 0; + g_autoptr(Msvm_VirtualSystemSettingData) vssd = NULL; + g_autoptr(Msvm_MemorySettingData) mem_sd = NULL; virUUIDFormat(domain->uuid, uuid_string); if (hypervGetMsvmVirtualSystemSettingDataFromUUID(priv, uuid_string, &vssd) < 0) - goto cleanup; + return 0; if (hypervGetMemorySD(priv, vssd->data->InstanceID, &mem_sd) < 0) - goto cleanup; - - maxMemoryBytes = mem_sd->data->Limit * 1024; - - cleanup: - hypervFreeObject((hypervObject *)vssd); - hypervFreeObject((hypervObject *)mem_sd); + return 0; - return maxMemoryBytes; + return mem_sd->data->Limit * 1024; }