[CRIU] [PATCH v2] criu: Fix open() retval analysing
Kirill Tkhai
ktkhai at virtuozzo.com
Thu Dec 1 01:22:17 PST 2016
Negative retval is error, while 0 is OK.
v2: More places
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
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 d52fe5c..e640096 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 acedb9b..9e56702 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 62b9b51..26f8b81 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);
}
More information about the CRIU
mailing list