From: Mathieu Desnoyers Date: Tue, 7 Feb 2012 04:00:01 +0000 (-0500) Subject: Zero-initialize struct msghdr X-Git-Tag: v1.9.6~8 X-Git-Url: https://git.lttng.org/?a=commitdiff_plain;h=913b87f139f795f334679472ad33e283869acc08;p=lttng-ust.git Zero-initialize struct msghdr Signed-off-by: Mathieu Desnoyers --- diff --git a/liblttng-ust-comm/lttng-ust-comm.c b/liblttng-ust-comm/lttng-ust-comm.c index b4fe11b0..3277191c 100644 --- a/liblttng-ust-comm/lttng-ust-comm.c +++ b/liblttng-ust-comm/lttng-ust-comm.c @@ -237,10 +237,12 @@ int ustcomm_listen_unix_sock(int sock) */ ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len) { - struct msghdr msg = { 0 }; + struct msghdr msg; struct iovec iov[1]; ssize_t ret = -1; + memset(&msg, 0, sizeof(msg)); + iov[0].iov_base = buf; iov[0].iov_len = len; msg.msg_iov = iov; @@ -262,10 +264,12 @@ ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len) */ ssize_t ustcomm_send_unix_sock(int sock, void *buf, size_t len) { - struct msghdr msg = { 0 }; + struct msghdr msg; struct iovec iov[1]; ssize_t ret = -1; + memset(&msg, 0, sizeof(msg)); + iov[0].iov_base = buf; iov[0].iov_len = len; msg.msg_iov = iov; @@ -311,13 +315,15 @@ int ustcomm_close_unix_sock(int sock) */ ssize_t ustcomm_send_fds_unix_sock(int sock, void *buf, int *fds, size_t nb_fd, size_t len) { - struct msghdr msg = { 0 }; + struct msghdr msg; struct cmsghdr *cmptr; struct iovec iov[1]; ssize_t ret = -1; unsigned int sizeof_fds = nb_fd * sizeof(int); char tmp[CMSG_SPACE(sizeof_fds)]; + memset(&msg, 0, sizeof(msg)); + /* * Note: the consumerd receiver only supports receiving one FD per * message. @@ -439,13 +445,15 @@ int ustcomm_recv_fd(int sock) int data_fd; struct cmsghdr *cmsg; char recv_fd[CMSG_SPACE(sizeof(int))]; - struct msghdr msg = { 0 }; + struct msghdr msg; union { unsigned char vc[4]; int vi; } tmp; int i; + memset(&msg, 0, sizeof(msg)); + /* Prepare to receive the structures */ iov[0].iov_base = &data_fd; iov[0].iov_len = sizeof(data_fd);