aboutsummaryrefslogtreecommitdiff
path: root/linux-user/main.c
diff options
context:
space:
mode:
authorMeador Inge <meadori@codesourcery.com>2015-07-06 11:03:40 -0700
committerRiku Voipio <riku.voipio@linaro.org>2015-09-28 16:04:20 +0300
commit138940bf08df1d8e9b862ad019a0d7d451e2413a (patch)
tree61c5d0eccdf628b4704ca6fb42afae672f09e5a9 /linux-user/main.c
parentdaaf8c8eb7135386134bc7075b9cf4dd57107c43 (diff)
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: Meador Inge <meadori@codesourcery.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Diffstat (limited to 'linux-user/main.c')
-rw-r--r--linux-user/main.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/linux-user/main.c b/linux-user/main.c
index 58d8d8dff5..31aa4d98e4 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -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];