Commit c1350f9a authored by Cyrill Gorcunov's avatar Cyrill Gorcunov

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: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent 093e4f35
This diff is collapsed.
......@@ -318,12 +318,15 @@ int main(int argc, char *argv[])
}
}
if (!log_inited && init_logging(NULL))
return 1;
if (!log_inited) {
ret = init_logging(NULL);
if (ret)
return ret;
}
if (getcwd(image_dir, sizeof(image_dir)) < 0) {
pr_perror("can't get currect directory\n");
return 1;
return -1;
}
switch (action) {
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment