[CRIU] [PATCH 13/28] rst: small cleanup patch

Kinsbursky Stanislav skinsbursky at openvz.org
Thu Mar 22 13:58:58 EDT 2012


From: Stanislav Kinsbursky <skinsbursky at openvz.org>

Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
 files.c         |   30 ++++++++++--------------------
 include/image.h |    8 ++++----
 2 files changed, 14 insertions(+), 24 deletions(-)
-------------- next part --------------
diff --git a/files.c b/files.c
index c0fa093..2b4872e 100644
--- a/files.c
+++ b/files.c
@@ -244,12 +244,12 @@ int prepare_fd_pid(int pid)
 	if (fdinfo_fd < 0) {
 		if (errno == ENOENT)
 			return 0;
-		else
-			return -1;
+		return -1;
 	}
 
 	while (1) {
 		struct fdinfo_entry e;
+		struct fd_entry *fde = &e.fde;
 
 		ret = read_img_eof(fdinfo_fd, &e);
 		if (ret <= 0)
@@ -258,10 +258,10 @@ int prepare_fd_pid(int pid)
 		if (e.len)
 			lseek(fdinfo_fd, e.len, SEEK_CUR);
 
-		if (fd_is_special(&e.fde))
+		if (fd_is_special(fde))
 			continue;
 
-		ret = collect_fd_pid(pid, &e.fde);
+		ret = collect_fd_pid(pid, fde);
 		if (ret < 0)
 			break;
 	}
@@ -649,20 +649,15 @@ static int open_fmap(int pid, struct fdinfo_entry *fe, int fd)
 	return 0;
 }
 
-static int open_fdinfo(int pid, struct fdinfo_entry *fe, int *fdinfo_fd, int state)
+static int open_fdinfo(int pid, struct fd_entry *fde, int *fdinfo_fd, int state)
 {
-	u32 mag;
-	int ret = 0;
+	int ret;
 	struct file_info *fi;
-	struct fd_entry *fde = &fe->fde;
 
-	if (move_img_fd(fdinfo_fd, (int)fe->addr))
+	if (move_img_fd(fdinfo_fd, fde->fd))
 		return -1;
 
-	pr_info("\t%d: Got fd for %lx type %d namelen %d\n", pid,
-			(unsigned long)fe->addr, fe->fde.type, fe->len);
-
-	BUG_ON(fe->fde.type != FDINFO_REG);
+	BUG_ON(fde->type != FDINFO_REG);
 
 	fi = file_search(fde->type, fde->id);
 	if (fi == NULL) {
@@ -708,13 +703,9 @@ static int open_special_fdinfo(int pid, struct fdinfo_entry *fe,
 
 int prepare_fds(int pid)
 {
-	u32 type = 0, err = -1, ret;
-	int fdinfo_fd;
-	int state;
+	int ret, err = -1, fdinfo_fd, state;
 	off_t offset, magic_offset;
-
 	struct fdinfo_entry fe;
-	int nr = 0;
 
 	pr_info("%d: Opening fdinfo-s\n", pid);
 
@@ -742,13 +733,12 @@ int prepare_fds(int pid)
 			if (fd_is_special(&fe.fde)) {
 				if (open_special_fdinfo(pid, &fe, fdinfo_fd, state))
 					goto err;
-
 				continue;
 			}
 
 			offset = lseek(fdinfo_fd, 0, SEEK_CUR);
 
-			if (open_fdinfo(pid, &fe, &fdinfo_fd, state))
+			if (open_fdinfo(pid, &fe.fde, &fdinfo_fd, state))
 				goto err;
 
 			lseek(fdinfo_fd, offset + fe.len, SEEK_SET);
diff --git a/include/image.h b/include/image.h
index 4b42226..62cf603 100644
--- a/include/image.h
+++ b/include/image.h
@@ -69,10 +69,10 @@ struct fdinfo_entry {
 	u8	name[0];
 } __packed;
 
-#define fd_is_special(fe)		\
-	(((fe)->type == FDINFO_MAP) ||	\
-	 ((fe)->type == FDINFO_CWD) ||	\
-	 ((fe)->type == FDINFO_EXE))
+#define fd_is_special(fde)		\
+	(((fde)->type == FDINFO_MAP) ||	\
+	 ((fde)->type == FDINFO_CWD) ||	\
+	 ((fde)->type == FDINFO_EXE))
 
 struct pstree_entry {
 	u32	pid;


More information about the CRIU mailing list