Move calls to virTypedParamsSerialize earlier in the event dispatch
functions so that we don't have to call 'xdr_free' afterwards.
This is possible as virTypedParamsSerialize cleans up after itself if it
fails.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/remote/remote_daemon_dispatch.c | 31 ++++++++++-------------------
1 file changed, 11 insertions(+), 20 deletions(-)
diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index 9d1fe5a095..d9fe589f4f 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -1032,16 +1032,17 @@ remoteRelayDomainEventTunable(virConnectPtr conn,
/* build return data */
memset(&data, 0, sizeof(data));
- data.callbackID = callback->callbackID;
- make_nonnull_domain(&data.dom, dom);
if (virTypedParamsSerialize(params, nparams,
REMOTE_DOMAIN_EVENT_TUNABLE_MAX,
(virTypedParameterRemotePtr *)
&data.params.params_val,
&data.params.params_len,
- VIR_TYPED_PARAM_STRING_OKAY) < 0) {
- goto error;
- }
+ VIR_TYPED_PARAM_STRING_OKAY) < 0)
+ return -1;
+
+ data.callbackID = callback->callbackID;
+ make_nonnull_domain(&data.dom, dom);
+
remoteDispatchObjectEventSend(callback->client, remoteProgram,
REMOTE_PROC_DOMAIN_EVENT_CALLBACK_TUNABLE,
@@ -1049,11 +1050,6 @@ remoteRelayDomainEventTunable(virConnectPtr conn,
&data);
return 0;
-
- error:
- xdr_free((xdrproc_t)xdr_remote_domain_event_callback_tunable_msg,
- (char *) &data);
- return -1;
}
@@ -1176,27 +1172,22 @@ remoteRelayDomainEventJobCompleted(virConnectPtr conn,
/* build return data */
memset(&data, 0, sizeof(data));
- data.callbackID = callback->callbackID;
- make_nonnull_domain(&data.dom, dom);
if (virTypedParamsSerialize(params, nparams,
REMOTE_DOMAIN_JOB_STATS_MAX,
(virTypedParameterRemotePtr *)
&data.params.params_val,
&data.params.params_len,
- VIR_TYPED_PARAM_STRING_OKAY) < 0) {
- goto error;
- }
+ VIR_TYPED_PARAM_STRING_OKAY) < 0)
+ return -1;
+
+ data.callbackID = callback->callbackID;
+ make_nonnull_domain(&data.dom, dom);
remoteDispatchObjectEventSend(callback->client, remoteProgram,
REMOTE_PROC_DOMAIN_EVENT_CALLBACK_JOB_COMPLETED,
(xdrproc_t)xdr_remote_domain_event_callback_job_completed_msg,
&data);
return 0;
-
- error:
- xdr_free((xdrproc_t)xdr_remote_domain_event_callback_job_completed_msg,
- (char *) &data);
- return -1;
}
--
2.21.0