From d49fac1ab6ab9727173065f3a69fc079d8947780 Mon Sep 17 00:00:00 2001 From: Kirill Tkhai Date: Thu, 1 Dec 2016 12:22:00 +0300 Subject: [PATCH] criu: Fix open() retval analysing Negative retval is error, while 0 is OK. v2: More places travis-ci: success for criu: Fix open() retval analysing Signed-off-by: Kirill Tkhai Acked-by: Cyrill Gorcunov Signed-off-by: Pavel Emelyanov --- criu/filesystems.c | 2 +- criu/sk-packet.c | 2 +- test/zdtm/static/binfmt_misc.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/criu/filesystems.c b/criu/filesystems.c index d52fe5c3a..e640096d8 100644 --- a/criu/filesystems.c +++ b/criu/filesystems.c @@ -213,7 +213,7 @@ static int write_binfmt_misc_entry(char *mp, char *buf, BinfmtMiscEntry *bme) snprintf(path, PATH_MAX, "%s/%s", mp, bme->name); fd = open(path, O_WRONLY); - if (!fd) { + if (fd < 0) { pr_perror("binfmt_misc: can't open %s", path); goto out; } diff --git a/criu/sk-packet.c b/criu/sk-packet.c index 6e0ad2d43..bcd4ff33e 100644 --- a/criu/sk-packet.c +++ b/criu/sk-packet.c @@ -325,7 +325,7 @@ static int open_socket_map(int pid, struct vma_area *vm) */ fd = dup(le->fe->fd); - if (!fd) { + if (fd < 0) { pr_perror("Can't dup packet sk"); return -1; } diff --git a/test/zdtm/static/binfmt_misc.c b/test/zdtm/static/binfmt_misc.c index 62b9b51e3..26f8b8192 100644 --- a/test/zdtm/static/binfmt_misc.c +++ b/test/zdtm/static/binfmt_misc.c @@ -120,7 +120,7 @@ int main(int argc, char **argv) /* Register binfmt_entries */ sprintf(path, "%s/" "register", dirname); fd = open(path, O_WRONLY); - if (!fd) { + if (fd < 0) { fail("open"); exit(1); } @@ -145,7 +145,7 @@ int main(int argc, char **argv) /* Disable one of the entries */ sprintf(path, "%s/%s", dirname, NAME[0]); fd = open(path, O_WRONLY); - if (!fd || write(fd, "0", 1) != 1) { + if (fd < 0 || write(fd, "0", 1) != 1) { fail("Can't disable %s\n", path); exit(1); }