Commit 09b7b57c authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Pavel Emelyanov

criu: don't return negative values from main() 2/2

We should return 1 not -1, because -1 becomes 255.

This is second part, patching return from functions.
Using 'ret != 0' condition seems like the best and easiest
thing to do, so we expect a function to return 0 in normal
case and any non-zero value in case of error.
Signed-off-by: 's avatarKir Kolyshkin <kir@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent f59326ab
...@@ -313,7 +313,7 @@ int main(int argc, char *argv[]) ...@@ -313,7 +313,7 @@ int main(int argc, char *argv[])
if (!strcmp(argv[optind], "dump")) { if (!strcmp(argv[optind], "dump")) {
if (!tree_id) if (!tree_id)
goto opt_pid_missing; goto opt_pid_missing;
return cr_dump_tasks(tree_id); return cr_dump_tasks(tree_id) != 0;
} }
if (!strcmp(argv[optind], "pre-dump")) { if (!strcmp(argv[optind], "pre-dump")) {
...@@ -330,31 +330,31 @@ int main(int argc, char *argv[]) ...@@ -330,31 +330,31 @@ int main(int argc, char *argv[])
opts.final_state = TASK_ALIVE; opts.final_state = TASK_ALIVE;
} }
return cr_pre_dump_tasks(tree_id); return cr_pre_dump_tasks(tree_id) != 0;
} }
if (!strcmp(argv[optind], "restore")) { if (!strcmp(argv[optind], "restore")) {
if (tree_id) if (tree_id)
pr_warn("Using -t with criu restore is obsoleted\n"); pr_warn("Using -t with criu restore is obsoleted\n");
return cr_restore_tasks(); return cr_restore_tasks() != 0;
} }
if (!strcmp(argv[optind], "show")) if (!strcmp(argv[optind], "show"))
return cr_show(pid); return cr_show(pid) != 0;
if (!strcmp(argv[optind], "check")) if (!strcmp(argv[optind], "check"))
return cr_check(); return cr_check() != 0;
if (!strcmp(argv[optind], "exec")) { if (!strcmp(argv[optind], "exec")) {
if (!pid) if (!pid)
pid = tree_id; /* old usage */ pid = tree_id; /* old usage */
if (!pid) if (!pid)
goto opt_pid_missing; goto opt_pid_missing;
return cr_exec(pid, argv + optind + 1); return cr_exec(pid, argv + optind + 1) != 0;
} }
if (!strcmp(argv[optind], "page-server")) if (!strcmp(argv[optind], "page-server"))
return cr_page_server(opts.restore_detach); return cr_page_server(opts.restore_detach) != 0;
if (!strcmp(argv[optind], "service")) if (!strcmp(argv[optind], "service"))
return cr_service(opts.restore_detach); return cr_service(opts.restore_detach);
......
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