[09/17] unix: Use generic xptr_pull in dump_one_unix_fd

Submitted by Cyrill Gorcunov on April 27, 2018, 11:34 a.m.

Details

Message ID 20180427113505.20616-10-gorcunov@gmail.com
State New
Series "unix: Add support for ghost unix sockets"
Headers show

Commit Message

Cyrill Gorcunov April 27, 2018, 11:34 a.m.
From: Cyrill Gorcunov <gorcunov@openvz.org>

To unify style of pointers fetching from memory slab.

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

Patch hide | download patch | download mbox

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);