]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
hyperv: enable usage of g_autoptr for hypervInvokeParamsList
authorMatt Coleman <mcoleman@datto.com>
Wed, 21 Oct 2020 08:46:05 +0000 (04:46 -0400)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 21 Oct 2020 12:20:33 +0000 (14:20 +0200)
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/hyperv/hyperv_driver.c
src/hyperv/hyperv_wmi.c
src/hyperv/hyperv_wmi.h

index 9ec2b879fcbccbb720c6925da4fe4fb71daf17f8..8f0cccdacd9e5992df45237d8fc572afbb01e826 100644 (file)
@@ -1619,7 +1619,7 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int codeset,
     Msvm_ComputerSystem *computerSystem = NULL;
     Msvm_Keyboard *keyboard = NULL;
     g_auto(virBuffer) query = VIR_BUFFER_INITIALIZER;
-    hypervInvokeParamsListPtr params = NULL;
+    g_autoptr(hypervInvokeParamsList) params = NULL;
     char keycodeStr[VIR_INT64_STR_BUFLEN];
 
     virCheckFlags(0, -1);
@@ -1672,10 +1672,8 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int codeset,
             goto cleanup;
         }
 
-        if (hypervAddSimpleParam(params, "keyCode", keycodeStr) < 0) {
-            hypervFreeInvokeParams(params);
+        if (hypervAddSimpleParam(params, "keyCode", keycodeStr) < 0)
             goto cleanup;
-        }
 
         if (hypervInvokeMethod(priv, &params, NULL) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not press key %d"),
@@ -1699,10 +1697,8 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int codeset,
             goto cleanup;
         }
 
-        if (hypervAddSimpleParam(params, "keyCode", keycodeStr) < 0) {
-            hypervFreeInvokeParams(params);
+        if (hypervAddSimpleParam(params, "keyCode", keycodeStr) < 0)
             goto cleanup;
-        }
 
         if (hypervInvokeMethod(priv, &params, NULL) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not release key %s"),
@@ -1730,7 +1726,7 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory,
     char uuid_string[VIR_UUID_STRING_BUFLEN];
     hypervPrivate *priv = domain->conn->privateData;
     char *memory_str = NULL;
-    hypervInvokeParamsListPtr params = NULL;
+    g_autoptr(hypervInvokeParamsList) params = NULL;
     unsigned long memory_mb = VIR_ROUND_UP(VIR_DIV_UP(memory, 1024), 2);
     Msvm_VirtualSystemSettingData *vssd = NULL;
     Msvm_MemorySettingData *memsd = NULL;
@@ -1814,7 +1810,7 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory,
     VIR_FREE(memory_str);
     hypervFreeObject(priv, (hypervObject *)vssd);
     hypervFreeObject(priv, (hypervObject *)memsd);
-    hypervFreeInvokeParams(params);
+
     return result;
 }
 
index 8bebf02a502d0c18d62182acfe65dc8ec3ade6bd..29447b8f0ff3ea926fa2f62e70b3d63598c8e1fe 100644 (file)
@@ -788,7 +788,7 @@ hypervInvokeMethod(hypervPrivate *priv,
                    hypervInvokeParamsListPtr *paramsPtr,
                    WsXmlDocH *res)
 {
-    hypervInvokeParamsListPtr params = *paramsPtr;
+    g_autoptr(hypervInvokeParamsList) params = *paramsPtr;
     int result = -1;
     size_t i = 0;
     int returnCode;
@@ -963,7 +963,6 @@ hypervInvokeMethod(hypervPrivate *priv,
     VIR_FREE(returnValue);
     VIR_FREE(instanceID);
     hypervFreeObject(priv, (hypervObject *)job);
-    hypervFreeInvokeParams(params);
     *paramsPtr = NULL;
     return result;
 }
index fa8e48a70ece8add846be9b181f9cdfadd62014f..3a623e99fa27280421f62c5a0118d7b9b1a4f5a5 100644 (file)
@@ -135,6 +135,7 @@ hypervInvokeParamsListPtr hypervCreateInvokeParamsList(hypervPrivate *priv,
         const char *method, const char *selector, hypervWmiClassInfoListPtr obj);
 
 void hypervFreeInvokeParams(hypervInvokeParamsListPtr params);
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(hypervInvokeParamsList, hypervFreeInvokeParams);
 
 int hypervAddSimpleParam(hypervInvokeParamsListPtr params, const char *name,
         const char *value);