[CRIU] Re: [PATCH] parasite: Simplify parasite command copying

Cyrill Gorcunov gorcunov at openvz.org
Thu Oct 11 13:15:53 EDT 2012


On Thu, Oct 11, 2012 at 09:04:02PM +0400, Pavel Emelyanov wrote:
> > 
> > Yup, this is a nit I missed, could you please fix it on top, or I should?
> 
> Plz, fix and send proper patch

Catch it :-)
-------------- next part --------------
>From d6a14f9f7269ea8d001f1b1b4282e298cb5dad97 Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Thu, 11 Oct 2012 17:59:10 +0400
Subject: [PATCH] parasite: Simplify parasite command copying

No need for memcpy here, it's plain integer value
which need to be filled.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 include/parasite-syscall.h |    2 +-
 parasite-syscall.c         |    5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/parasite-syscall.h b/include/parasite-syscall.h
index 8338d3d..aad6565 100644
--- a/include/parasite-syscall.h
+++ b/include/parasite-syscall.h
@@ -17,7 +17,7 @@ struct parasite_ctl {
 
 	int			signals_blocked;
 
-	void 			* addr_cmd;				/* addr for command */
+	unsigned int		* addr_cmd;				/* addr for command */
 	void 			* addr_args;				/* address for arguments */
 	int			tsock;					/* transport socket for transfering fds */
 };
diff --git a/parasite-syscall.c b/parasite-syscall.c
index 1118ef2..89ab1ba 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -244,7 +244,8 @@ static int parasite_execute_by_pid(unsigned int cmd, struct parasite_ctl *ctl, p
 		regs = regs_orig;
 	}
 
-	memcpy(ctl->addr_cmd, &cmd, sizeof(cmd));
+	/* Setup command */
+	*ctl->addr_cmd = cmd;
 
 	parasite_setup_regs(ctl->parasite_ip, &regs);
 
@@ -807,7 +808,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct list_head *vma_are
 
 	/* Setup the rest of a control block */
 	ctl->parasite_ip	= PARASITE_HEAD_ADDR((unsigned long)ctl->remote_map);
-	ctl->addr_cmd		= (void *)PARASITE_CMD_ADDR((unsigned long)ctl->local_map);
+	ctl->addr_cmd		= (unsigned int *)PARASITE_CMD_ADDR((unsigned long)ctl->local_map);
 	ctl->addr_args		= (void *)PARASITE_ARGS_ADDR((unsigned long)ctl->local_map);
 
 	ret = parasite_init(ctl, pid);
-- 
1.7.7.6



More information about the CRIU mailing list