提交 138940bf 编写于 作者: M Meador Inge 提交者: Riku Voipio

linux-user: Add proper error messages for bad options

This patch adds better support for diagnosing option
parser errors.  The previous implementation just printed
the usage text and exited when a bad option or argument
was found.  This made it very difficult to determine why
the usage was being displayed and it was doubly confusing
for cases like '--help' (it wasn't clear that --help was
actually an error).
Signed-off-by: NMeador Inge <meadori@codesourcery.com>
Signed-off-by: NRiku Voipio <riku.voipio@linaro.org>
上级 daaf8c8e
......@@ -4029,7 +4029,9 @@ static int parse_args(int argc, char **argv)
if (!strcmp(r, arginfo->argv)) {
if (arginfo->has_arg) {
if (optind >= argc) {
usage(1);
(void) fprintf(stderr,
"qemu: missing argument for option '%s'\n", r);
exit(1);
}
arginfo->handle_opt(argv[optind]);
optind++;
......@@ -4042,12 +4044,14 @@ static int parse_args(int argc, char **argv)
/* no option matched the current argv */
if (arginfo->handle_opt == NULL) {
usage(1);
(void) fprintf(stderr, "qemu: unknown option '%s'\n", r);
exit(1);
}
}
if (optind >= argc) {
usage(1);
(void) fprintf(stderr, "qemu: no user program specified\n");
exit(1);
}
filename = argv[optind];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册