[libvirt] [PATCH 4/4] remote_daemon_dispatch: Don't open code xdr_free()

Michal Privoznik mprivozn at redhat.com
Tue Aug 27 12:05:09 UTC 2019


At two places we are open coding xdr_free():
remoteRelayDomainEventTunable() and
remoteRelayDomainEventJobCompleted().
Bot of these functions use make_nonnull_domain() to put domain
IDs tuple into return structure and then continue encoding the
rest of structure. If that fails, they call VIR_FREE() directly.
While this okay, we should use xdr_free() which frees the whole
return structure for us.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/remote/remote_daemon_dispatch.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index c658a6e115..ecde959088 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -1156,8 +1156,7 @@ remoteRelayDomainEventTunable(virConnectPtr conn,
                                 (virTypedParameterRemotePtr *) &data.params.params_val,
                                 &data.params.params_len,
                                 VIR_TYPED_PARAM_STRING_OKAY) < 0) {
-        VIR_FREE(data.dom.name);
-        return -1;
+        goto error;
     }
 
     remoteDispatchObjectEventSend(callback->client, remoteProgram,
@@ -1323,8 +1322,7 @@ remoteRelayDomainEventJobCompleted(virConnectPtr conn,
                                 (virTypedParameterRemotePtr *) &data.params.params_val,
                                 &data.params.params_len,
                                 VIR_TYPED_PARAM_STRING_OKAY) < 0) {
-        VIR_FREE(data.dom.name);
-        return -1;
+        goto error;
     }
 
     remoteDispatchObjectEventSend(callback->client, remoteProgram,
-- 
2.21.0




More information about the libvir-list mailing list