[CRIU] [crtools-bot for Cyrill Gorcunov ] util-net: Zeroify structures

Cyrill Gorcunov gorcunov at openvz.org
Tue Feb 14 08:18:09 EST 2012


The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
------>
commit f130df9234ea846839a9747335666c3669192466
Author: Cyrill Gorcunov <gorcunov at openvz.org>
Date:   Thu Feb 9 19:09:09 2012 +0400

    util-net: Zeroify structures
    
    Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
    Acked-by: Pavel Emelyanov <xemul at parallels.com>
---
 util-net.c |   36 +++++++++++++++++-------------------
 1 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/util-net.c b/util-net.c
index 0bc6490..4f826ca 100644
--- a/util-net.c
+++ b/util-net.c
@@ -5,21 +5,20 @@
 
 int send_fd(int sock, struct sockaddr_un *saddr, int len, int fd)
 {
-	struct msghdr hdr;
-	struct iovec data;
 	char cmsgbuf[CMSG_SPACE(sizeof(int))];
+	struct msghdr hdr = { };
+	struct iovec data = { };
 	struct cmsghdr* cmsg;
 	int *cmsg_data;
 	char dummy = '*';
 
-	data.iov_base = &dummy;
-	data.iov_len = sizeof(dummy);
+	data.iov_base	= &dummy;
+	data.iov_len	= sizeof(dummy);
 
-	hdr.msg_name = (struct sockaddr *)saddr;
-	hdr.msg_namelen = len;
-	hdr.msg_iov = &data;
-	hdr.msg_iovlen = 1;
-	hdr.msg_flags = 0;
+	hdr.msg_name	= (struct sockaddr *)saddr;
+	hdr.msg_namelen	= len;
+	hdr.msg_iov	= &data;
+	hdr.msg_iovlen	= 1;
 
 	hdr.msg_control = &cmsgbuf;
 	hdr.msg_controllen = CMSG_LEN(sizeof(int));
@@ -37,21 +36,20 @@ int send_fd(int sock, struct sockaddr_un *saddr, int len, int fd)
 
 int recv_fd(int sock)
 {
-	struct msghdr msg;
-	struct iovec iov;
-	char buf[1];
 	char ccmsg[CMSG_SPACE(sizeof(int))];
+	struct msghdr msg = { };
+	struct iovec iov = { };
 	struct cmsghdr *cmsg;
 	int *cmsg_data;
-	iov.iov_base = buf;
-	iov.iov_len = 1;
+	char buf[1];
 	int ret;
 
-	msg.msg_name = 0;
-	msg.msg_namelen = 0;
-	msg.msg_iov = &iov;
-	msg.msg_iovlen = 1;
-	msg.msg_control = ccmsg;
+	iov.iov_base	= buf;
+	iov.iov_len	= 1;
+
+	msg.msg_iov	= &iov;
+	msg.msg_iovlen	= 1;
+	msg.msg_control	= ccmsg;
 	msg.msg_controllen = sizeof(ccmsg);
 
 	ret = sys_recvmsg(sock, &msg, 0);


More information about the CRIU mailing list