From a5483337b31389dda90055b6620d8662ffe3baf4 Mon Sep 17 00:00:00 2001 From: Kirill Tkhai Date: Wed, 7 Jun 2017 14:24:01 +0300 Subject: [PATCH] utils: Cleanup open_fd_of_vpid() Move +1 up to snprintf(). Signed-off-by: Kirill Tkhai Signed-off-by: Andrei Vagin --- criu/util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/criu/util.c b/criu/util.c index 31e30bd80..845f9158b 100644 --- a/criu/util.c +++ b/criu/util.c @@ -1413,14 +1413,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 /proc/%s on the criu side\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;