2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00

Make error codes returned being a negative value

We have a mess in our return codes:
some functions return negative values,
while others -- positive.

Sanitize the return codes and make error
condition to return negative values.

Reported-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This commit is contained in:
Cyrill Gorcunov
2011-12-13 15:03:33 +04:00
parent 093e4f35c3
commit c1350f9ab1
3 changed files with 84 additions and 81 deletions

6
util.c
View File

@@ -51,19 +51,19 @@ int init_logging(const char *name)
fd = open(name, O_CREAT | O_WRONLY);
if (fd == -1) {
pr_perror("Can't create log file %s\n", name);
return 1;
return -1;
}
}
if (getrlimit(RLIMIT_NOFILE, &rlimit)) {
pr_err("can't get rlimit: %m\n");
return 1;
return -1;
}
logfd = rlimit.rlim_cur - 1;
if (dup2(fd, logfd) < 0) {
pr_err("can't duplicate descriptor 2->%d: %m\n", logfd);
return 1;
return -1;
}
return 0;