Commit 7e3b9079 authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Pavel Emelyanov

criu: don't show long usage in case of error

* Don't show long usage in case of usage error, otherwise an actual
  error message will be lost in long output.

* Print error if command is not specified.

* Return 0 if criu --help is used.
Signed-off-by: 's avatarKir Kolyshkin <kir@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 5d12a116
...@@ -79,6 +79,7 @@ int main(int argc, char *argv[]) ...@@ -79,6 +79,7 @@ int main(int argc, char *argv[])
{ {
pid_t pid = 0, tree_id = 0; pid_t pid = 0, tree_id = 0;
int ret = -1; int ret = -1;
bool usage_error = true;
int opt, idx; int opt, idx;
int log_level = 0; int log_level = 0;
char *imgs_dir = "."; char *imgs_dir = ".";
...@@ -293,6 +294,8 @@ int main(int argc, char *argv[]) ...@@ -293,6 +294,8 @@ int main(int argc, char *argv[])
pr_msg("GitID: %s\n", CRIU_GITID); pr_msg("GitID: %s\n", CRIU_GITID);
return 0; return 0;
case 'h': case 'h':
usage_error = false;
goto usage;
default: default:
goto usage; goto usage;
} }
...@@ -301,8 +304,10 @@ int main(int argc, char *argv[]) ...@@ -301,8 +304,10 @@ int main(int argc, char *argv[])
if (work_dir == NULL) if (work_dir == NULL)
work_dir = imgs_dir; work_dir = imgs_dir;
if (optind >= argc) if (optind >= argc) {
pr_msg("Error: command is required\n");
goto usage; goto usage;
}
/* We must not open imgs dir, if service is called */ /* We must not open imgs dir, if service is called */
if (strcmp(argv[optind], "service")) { if (strcmp(argv[optind], "service")) {
...@@ -401,7 +406,7 @@ usage: ...@@ -401,7 +406,7 @@ usage:
" dedup remove duplicates in memory dump\n" " dedup remove duplicates in memory dump\n"
); );
if (argc < 2) { if (usage_error) {
pr_msg("\nTry -h|--help for more info\n"); pr_msg("\nTry -h|--help for more info\n");
return 1; return 1;
} }
...@@ -465,7 +470,7 @@ usage: ...@@ -465,7 +470,7 @@ usage:
" --ms don't check not yet merged kernel features\n" " --ms don't check not yet merged kernel features\n"
); );
return 1; return 0;
opt_pid_missing: opt_pid_missing:
pr_msg("Error: pid not specified\n"); pr_msg("Error: pid not specified\n");
......
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