[v4,10/41] pstree: Introduce PID_SIZE() helper

Submitted by Kirill Tkhai on May 4, 2017, 4:06 p.m.

Details

Message ID 149391398239.11711.11765687670724805864.stgit@localhost.localdomain
State New
Series "Nested pid namespaces support"
Headers show

Commit Message

Kirill Tkhai May 4, 2017, 4:06 p.m.
We will use this expression in more places.

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

Patch hide | download patch | download mbox

diff --git a/criu/include/pstree.h b/criu/include/pstree.h
index 313d85666..313b77458 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 315f533ba..8e8064009 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);