[CRIU] [PATCH v5 09/21] unix: Use generic xptr_pull in dump_one_unix_fd

Cyrill Gorcunov gorcunov at gmail.com
Thu May 10 17:57:49 MSK 2018


From: Cyrill Gorcunov <gorcunov at openvz.org>

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 83e84929b625..75b853846f51 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -324,17 +324,18 @@ static int dump_one_unix_fd(int lfd, uint32_t 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.14.3



More information about the CRIU mailing list