[CRIU] [PATCH 09/18] sk-unix: Use generic xptr_pull in dump_one_unix_fd

Cyrill Gorcunov gorcunov at openvz.org
Wed Apr 12 06:58:29 PDT 2017


To unify style of pointers fetching from memory slab.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 criu/sk-unix.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index 0bd6f3670324..22eb8ddabdaf 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -263,17 +263,18 @@ static int dump_one_unix_fd(int lfd, u32 id, const struct fd_parms *p)
 	SkOptsEntry *skopts;
 	FilePermsEntry *perms;
 	FownEntry *fown;
+	void *m;
 
-	ue = xmalloc(sizeof(UnixSkEntry) +
-			sizeof(SkOptsEntry) +
-			sizeof(FilePermsEntry) +
-			sizeof(FownEntry));
-	if (ue == NULL)
-		return -1;
-
-	skopts = (void *) ue + sizeof(UnixSkEntry);
-	perms = (void *) skopts + sizeof(SkOptsEntry);
-	fown = (void *) perms + sizeof(FilePermsEntry);
+	m = xmalloc(sizeof(UnixSkEntry) +
+		    sizeof(SkOptsEntry) +
+		    sizeof(FilePermsEntry) +
+		    sizeof(FownEntry));
+	if (!m)
+		return -ENOMEM;
+	ue	= xptr_pull(&m, UnixSkEntry);
+	skopts	= xptr_pull(&m, SkOptsEntry);
+	perms	= xptr_pull(&m, FilePermsEntry);
+	fown	= xptr_pull(&m, FownEntry);
 
 	unix_sk_entry__init(ue);
 	sk_opts_entry__init(skopts);
-- 
2.7.4



More information about the CRIU mailing list