[CRIU] [PATCH 08/28] utils: Cleanup open_fd_of_vpid()

Kirill Tkhai ktkhai at virtuozzo.com
Mon Jun 5 20:24:40 MSK 2017


Move +1 up to snprintf().

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/util.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/criu/util.c b/criu/util.c
index 93337760b..3cd55180f 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -1236,14 +1236,14 @@ int open_fd_of_vpid(pid_t pid, int fd, int flags)
 	int ret;
 
 	item = pstree_pid_by_virt(pid)->item;
-	ret = sprintf(path, "%d/fd/%d", item->pid->real, fd);
+	ret = sprintf(path, "%d/fd/%d", item->pid->real, fd) + 1;
 	pr_info("Opening real [%s]\n", path);
 	if (flags == O_RDONLY)
-		ret = userns_call(fn_open_proc_r, UNS_FDOUT, path, ret + 1, -1);
+		ret = userns_call(fn_open_proc_r, UNS_FDOUT, path, ret, -1);
 	else if (flags == O_WRONLY)
-		ret = userns_call(fn_open_proc_w, UNS_FDOUT, path, ret + 1, -1);
+		ret = userns_call(fn_open_proc_w, UNS_FDOUT, path, ret, -1);
 	else if (flags == O_RDWR)
-		ret = userns_call(fn_open_proc_rw, UNS_FDOUT, path, ret + 1, -1);
+		ret = userns_call(fn_open_proc_rw, UNS_FDOUT, path, ret, -1);
 	else
 		BUG();
 	return ret;



More information about the CRIU mailing list