[CRIU] [PATCH 01/11] vma: Add vma_next() helper

Pavel Emelyanov xemul at virtuozzo.com
Thu May 11 02:10:42 PDT 2017


Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/cr-restore.c  | 4 ++--
 criu/include/vma.h | 5 +++++
 criu/mem.c         | 2 +-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 3481362..c746732 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -2487,7 +2487,7 @@ static long restorer_get_vma_hint(struct list_head *tgt_vma_list,
 				break;
 			if (prev_vma_end < s_vma->e->end)
 				prev_vma_end = s_vma->e->end;
-			s_vma = list_entry(s_vma->list.next, struct vma_area, list);
+			s_vma = vma_next(s_vma);
 			continue;
 		}
 
@@ -2500,7 +2500,7 @@ static long restorer_get_vma_hint(struct list_head *tgt_vma_list,
 				break;
 			if (prev_vma_end < t_vma->e->end)
 				prev_vma_end = t_vma->e->end;
-			t_vma = list_entry(t_vma->list.next, struct vma_area, list);
+			t_vma = vma_next(t_vma);
 			continue;
 		}
 
diff --git a/criu/include/vma.h b/criu/include/vma.h
index 37f8b4b..8c46350 100644
--- a/criu/include/vma.h
+++ b/criu/include/vma.h
@@ -115,4 +115,9 @@ static inline bool vma_entry_can_be_lazy(VmaEntry *e)
 		!(vma_entry_is(e, VMA_AREA_VSYSCALL)));
 }
 
+static inline struct vma_area *vma_next(struct vma_area *vma)
+{
+	return list_entry(vma->list.next, struct vma_area, list);
+}
+
 #endif /* __CR_VMA_H__ */
diff --git a/criu/mem.c b/criu/mem.c
index 3bcf467..2db8dd5 100644
--- a/criu/mem.c
+++ b/criu/mem.c
@@ -770,7 +770,7 @@ static int restore_priv_vma_content(struct pstree_item *t)
 			while (va >= vma->e->end) {
 				if (vma->list.next == vmas)
 					goto err_addr;
-				vma = list_entry(vma->list.next, struct vma_area, list);
+				vma = vma_next(vma);
 			}
 
 			/*
-- 
2.1.4



More information about the CRIU mailing list