Few events emit optional strings. We need to allocate the container for
it first. Note that remote_nonnull_string is used as the type as the
internal part of the string is nonnull if the container is present.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/remote/remote_daemon_dispatch.c | 27 ++++-----------------------
1 file changed, 4 insertions(+), 23 deletions(-)
diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index 392a32fed8..9d1fe5a095 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -721,14 +721,12 @@ remoteRelayDomainEventDiskChange(virConnectPtr conn,
/* build return data */
memset(&data, 0, sizeof(data));
if (oldSrcPath) {
- if (VIR_ALLOC(data.oldSrcPath) < 0)
- goto error;
+ data.oldSrcPath = g_new0(remote_nonnull_string, 1);
*(data.oldSrcPath) = g_strdup(oldSrcPath);
}
if (newSrcPath) {
- if (VIR_ALLOC(data.newSrcPath) < 0)
- goto error;
+ data.newSrcPath = g_new0(remote_nonnull_string, 1);
*(data.newSrcPath) = g_strdup(newSrcPath);
}
@@ -750,11 +748,6 @@ remoteRelayDomainEventDiskChange(virConnectPtr conn,
}
return 0;
-
- error:
- xdr_free((xdrproc_t)xdr_remote_domain_event_disk_change_msg,
- (char *) &data);
- return -1;
}
@@ -1262,8 +1255,7 @@ remoteRelayDomainEventMetadataChange(virConnectPtr conn,
data.type = type;
if (nsuri) {
- if (VIR_ALLOC(data.nsuri) < 0)
- goto error;
+ data.nsuri = g_new0(remote_nonnull_string, 1);
*(data.nsuri) = g_strdup(nsuri);
}
@@ -1276,11 +1268,6 @@ remoteRelayDomainEventMetadataChange(virConnectPtr conn,
&data);
return 0;
-
- error:
- xdr_free((xdrproc_t)xdr_remote_domain_event_callback_metadata_change_msg,
- (char *) &data);
- return -1;
}
@@ -1308,8 +1295,7 @@ remoteRelayDomainEventBlockThreshold(virConnectPtr conn,
data.callbackID = callback->callbackID;
data.dev = g_strdup(dev);
if (path) {
- if (VIR_ALLOC(data.path) < 0)
- goto error;
+ data.path = g_new0(remote_nonnull_string, 1);
*(data.path) = g_strdup(path);
}
data.threshold = threshold;
@@ -1321,11 +1307,6 @@ remoteRelayDomainEventBlockThreshold(virConnectPtr conn,
(xdrproc_t)xdr_remote_domain_event_block_threshold_msg,
&data);
return 0;
-
- error:
- xdr_free((xdrproc_t)xdr_remote_domain_event_block_threshold_msg,
- (char *) &data);
- return -1;
}
--
2.21.0