[CRIU] [PATCH v5 11/42] pstree: Introduce PID_SIZE() helper

Kirill Tkhai ktkhai at virtuozzo.com
Fri May 5 09:14:18 PDT 2017


We will use this expression in more places.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/include/pstree.h |    2 ++
 criu/pstree.c         |    2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/criu/include/pstree.h b/criu/include/pstree.h
index 4cd98e122..d7f052a22 100644
--- a/criu/include/pstree.h
+++ b/criu/include/pstree.h
@@ -37,6 +37,8 @@ struct pstree_item {
 #define vpgid(item)	(item->pgid->ns[0].virt)
 #define vtid(item, i)	(item->threads[i]->ns[0].virt)
 
+#define PID_SIZE(level) (sizeof(struct pid) + (level-1) * sizeof(((struct pid *)NULL)->ns[0]))
+
 enum {
 	FDS_EVENT_BIT	= 0,
 };
diff --git a/criu/pstree.c b/criu/pstree.c
index 7b7189aa2..dc99e4240 100644
--- a/criu/pstree.c
+++ b/criu/pstree.c
@@ -208,7 +208,7 @@ struct pstree_item *__alloc_pstree_item(bool rst, int level)
 	struct pstree_item *item;
 	int sz, p_sz;
 
-	p_sz = sizeof(struct pid) + (level - 1) * sizeof(((struct pid *)NULL)->ns[0]);
+	p_sz = PID_SIZE(level);
 	if (!rst) {
 		sz = sizeof(*item) + sizeof(struct dmp_info);
 		item = xzalloc(sz);



More information about the CRIU mailing list