[CRIU] [crtools-bot] files: Get rid of strict-aliasing violations

Cyrill Gorcunov gorcunov at openvz.org
Wed Feb 1 08:35:05 EST 2012


The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
------>
commit 339ad2d887185d0f2cd358593a5805c2ff0a6775
Author: Cyrill Gorcunov <gorcunov at openvz.org>
Date:   Wed Feb 1 15:54:04 2012 +0400

    files: Get rid of strict-aliasing violations
    
    Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 files.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/files.c b/files.c
index a1ff413..abcf882 100644
--- a/files.c
+++ b/files.c
@@ -329,7 +329,8 @@ static int open_fd(int pid, struct fdinfo_entry *fe,
 		struct msghdr hdr;
 		struct iovec data;
 		char cmsgbuf[CMSG_SPACE(sizeof(int))];
-		struct cmsghdr* cmsg;
+		struct cmsghdr *cmsg;
+		int *cmsg_data;
 
 		char dummy = '*';
 
@@ -365,7 +366,8 @@ static int open_fd(int pid, struct fdinfo_entry *fe,
 		cmsg->cmsg_level = SOL_SOCKET;
 		cmsg->cmsg_type  = SCM_RIGHTS;
 
-		*(int*)CMSG_DATA(cmsg) = fe->addr;
+		cmsg_data = (int *)CMSG_DATA(cmsg);
+		*cmsg_data = fe->addr;
 
 		tmp = sendmsg(sock, &hdr, 0);
 		if (tmp < 0) {
@@ -387,6 +389,7 @@ static int recv_fd(int sock)
 	char buf[1];
 	char ccmsg[CMSG_SPACE(sizeof(int))];
 	struct cmsghdr *cmsg;
+	int *cmsg_data;
 	iov.iov_base = buf;
 	iov.iov_len = 1;
 	int ret;
@@ -411,7 +414,8 @@ static int recv_fd(int sock)
 		return -1;
 	}
 
-	return *(int*)CMSG_DATA(cmsg);
+	cmsg_data = (int *)CMSG_DATA(cmsg);
+	return *cmsg_data;
 }
 
 static int receive_fd(int pid, struct fdinfo_entry *fe, struct fdinfo_desc *fi)


More information about the CRIU mailing list