[PATCH 5/5] hyperv: Simplify @memResource freeing in hypervDomainSetMemoryFlags()

Michal Privoznik posted 5 patches 4 years, 1 month ago
[PATCH 5/5] hyperv: Simplify @memResource freeing in hypervDomainSetMemoryFlags()
Posted by Michal Privoznik 4 years, 1 month ago
Now, that ownership transfer of hypervSetEmbeddedProperty() is
clear, we can use automatic freeing of the hash table.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/hyperv/hyperv_driver.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index cae284db0b..9ec2b879fc 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -1735,7 +1735,7 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory,
     Msvm_VirtualSystemSettingData *vssd = NULL;
     Msvm_MemorySettingData *memsd = NULL;
     g_auto(virBuffer) eprQuery = VIR_BUFFER_INITIALIZER;
-    virHashTablePtr memResource = NULL;
+    g_autoptr(virHashTable) memResource = NULL;
 
     virCheckFlags(0, -1);
 
@@ -1781,21 +1781,17 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory,
     if (!memResource)
         goto cleanup;
 
-    if (hypervSetEmbeddedProperty(memResource, "VirtualQuantity", memory_str) < 0) {
-        hypervFreeEmbeddedParam(memResource);
+    if (hypervSetEmbeddedProperty(memResource, "VirtualQuantity", memory_str) < 0)
         goto cleanup;
-    }
 
     if (hypervSetEmbeddedProperty(memResource, "InstanceID",
                 memsd->data.common->InstanceID) < 0) {
-        hypervFreeEmbeddedParam(memResource);
         goto cleanup;
     }
 
     if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) {
         if (hypervAddEmbeddedParam(params, priv, "ResourceSettingData",
                                    &memResource, Msvm_MemorySettingData_WmiInfo) < 0) {
-            hypervFreeEmbeddedParam(memResource);
             goto cleanup;
         }
 
-- 
2.26.2