[CRIU] [PATCH 7/9] vdso: Cleanup vdso_do_park()

Dmitry Safonov dsafonov at virtuozzo.com
Thu Jun 22 14:04:30 MSK 2017


Make it a bit easier to read.

Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 criu/pie/parasite-vdso.c | 46 +++++++++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/criu/pie/parasite-vdso.c b/criu/pie/parasite-vdso.c
index 3f3dfae99d7e..ce744a87cd3a 100644
--- a/criu/pie/parasite-vdso.c
+++ b/criu/pie/parasite-vdso.c
@@ -41,30 +41,34 @@ static int vdso_remap(char *who, unsigned long from, unsigned long to, size_t si
 	return 0;
 }
 
-/* Park runtime vDSO in some safe place where it can be accessible from restorer */
-int vdso_do_park(struct vdso_maps *rt, unsigned long park_at, unsigned long park_size)
+/*
+ * Park runtime vDSO in some safe place where it can be accessible
+ * from the restorer
+ */
+int vdso_do_park(struct vdso_maps *rt, unsigned long park_at,
+		unsigned long park_size)
 {
+	unsigned long vvar_size = rt->sym.vvar_size;
+	unsigned long vdso_size = rt->sym.vdso_size;
+	unsigned long rt_vvar_park = park_at;
+	unsigned long rt_vdso_park = park_at;
 	int ret;
 
-	BUG_ON((rt->sym.vdso_size + rt->sym.vvar_size) < park_size);
-
-	if (rt->vvar_start != VVAR_BAD_ADDR) {
-		if (rt->sym.vdso_before_vvar) {
-			ret  = vdso_remap("rt-vdso", rt->vdso_start,
-					  park_at, rt->sym.vdso_size);
-			park_at += rt->sym.vdso_size;
-			ret |= vdso_remap("rt-vvar", rt->vvar_start,
-					  park_at, rt->sym.vvar_size);
-		} else {
-			ret  = vdso_remap("rt-vvar", rt->vvar_start,
-					  park_at, rt->sym.vvar_size);
-			park_at += rt->sym.vvar_size;
-			ret |= vdso_remap("rt-vdso", rt->vdso_start,
-					  park_at, rt->sym.vdso_size);
-		}
-	} else
-		ret = vdso_remap("rt-vdso", rt->vdso_start,
-				 park_at, rt->sym.vdso_size);
+	BUG_ON((vdso_size + vvar_size) < park_size);
+
+	if (rt->vvar_start == VVAR_BAD_ADDR) {
+		return vdso_remap("rt-vdso", rt->vdso_start,
+				rt_vdso_park, vdso_size);
+	}
+
+	if (rt->sym.vdso_before_vvar)
+		rt_vvar_park = park_at + vdso_size;
+	else
+		rt_vdso_park = park_at + vvar_size;
+
+	ret  = vdso_remap("rt-vdso", rt->vdso_start, rt_vdso_park, vdso_size);
+	ret |= vdso_remap("rt-vvar", rt->vvar_start, rt_vvar_park, vvar_size);
+
 	return ret;
 }
 
-- 
2.13.1



More information about the CRIU mailing list