[13/15] restore: Cleanup ptrs remapping code done so far

Submitted by Pavel Emelianov on May 24, 2016, 11:36 a.m.

Details

Message ID 57443CCF.7050009@virtuozzo.com
State Superseded
Commit 31093de788b377cd72af25d0c7ddfaef39c058cb
Headers show

Commit Message

Pavel Emelianov May 24, 2016, 11:36 a.m.
After all arrays remapping is reworked, the remap_array() can
be dropped from code and in-place ptr fixup helper can appear.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 criu/cr-restore.c         | 27 ++++++++++-----------------
 criu/include/rst-malloc.h |  4 ++++
 2 files changed, 14 insertions(+), 17 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index b920cdd..948b4a0 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -2856,23 +2856,16 @@  static int sigreturn_restore(pid_t pid, unsigned long ta_cp, CoreEntry *core)
 
 	task_args->task_size = kdat.task_size;
 
-	task_args->vmas = rst_mem_remap_ptr((unsigned long)task_args->vmas, RM_PRIVATE);
-	task_args->rings = rst_mem_remap_ptr((unsigned long)task_args->rings, RM_PRIVATE);
-	task_args->tcp_socks = rst_mem_remap_ptr((unsigned long)task_args->tcp_socks, RM_PRIVATE);
-	task_args->timerfd = rst_mem_remap_ptr((unsigned long)task_args->timerfd, RM_PRIVATE);
-	task_args->posix_timers = rst_mem_remap_ptr((unsigned long)task_args->posix_timers, RM_PRIVATE);
-	task_args->siginfo = rst_mem_remap_ptr((unsigned long)task_args->siginfo, RM_PRIVATE);
-	task_args->rlims = rst_mem_remap_ptr((unsigned long)task_args->rlims, RM_PRIVATE);
-	task_args->helpers = rst_mem_remap_ptr((unsigned long)task_args->helpers, RM_PRIVATE);
-	task_args->zombies = rst_mem_remap_ptr((unsigned long)task_args->zombies, RM_PRIVATE);
-	task_args->seccomp_filters = rst_mem_remap_ptr((unsigned long)task_args->seccomp_filters, RM_PRIVATE);
-
-#define remap_array(name, nr, cpos)	do {				\
-		task_args->name##_n = nr;				\
-		task_args->name = rst_mem_remap_ptr(cpos, RM_PRIVATE);	\
-	} while (0)
-
-#undef remap_array
+	RST_MEM_FIXUP_PPTR(task_args->vmas);
+	RST_MEM_FIXUP_PPTR(task_args->rings);
+	RST_MEM_FIXUP_PPTR(task_args->tcp_socks);
+	RST_MEM_FIXUP_PPTR(task_args->timerfd);
+	RST_MEM_FIXUP_PPTR(task_args->posix_timers);
+	RST_MEM_FIXUP_PPTR(task_args->siginfo);
+	RST_MEM_FIXUP_PPTR(task_args->rlims);
+	RST_MEM_FIXUP_PPTR(task_args->helpers);
+	RST_MEM_FIXUP_PPTR(task_args->zombies);
+	RST_MEM_FIXUP_PPTR(task_args->seccomp_filters);
 
 	if (core->tc->has_seccomp_mode)
 		task_args->seccomp_mode = core->tc->seccomp_mode;
diff --git a/criu/include/rst-malloc.h b/criu/include/rst-malloc.h
index fafef2b..67391ba 100644
--- a/criu/include/rst-malloc.h
+++ b/criu/include/rst-malloc.h
@@ -52,6 +52,10 @@  extern void rst_mem_switch_to_private(void);
  */
 extern unsigned long rst_mem_align_cpos(int type);
 extern void *rst_mem_remap_ptr(unsigned long pos, int type);
+#define RST_MEM_FIXUP_PPTR(ptr) do {				\
+	ptr = rst_mem_remap_ptr((unsigned long)ptr, RM_PRIVATE);\
+} while (0)
+
 /*
  * Allocate and free objects. We don't need to free arbitrary
  * object, thus allocation is simple (linear) and only the