[CRIU] [PATCH v4 10/41] pstree: Introduce PID_SIZE() helper
Kirill Tkhai
ktkhai at virtuozzo.com
Thu May 4 09:06:22 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 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);
More information about the CRIU
mailing list