[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 03/13] linux-user: Add proper error messages for bad
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PULL 03/13] linux-user: Add proper error messages for bad options |
Date: |
Fri, 2 Oct 2015 16:00:55 +0300 |
From: Meador Inge <address@hidden>
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 <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
---
linux-user/main.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index 58d8d8d..31aa4d9 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];
--
2.5.3
- [Qemu-devel] [PULL 00/13] linux-user queque, riku . voipio, 2015/10/08
- [Qemu-devel] [PULL 10/13] linux-user: add name_to_handle_at/open_by_handle_at, riku . voipio, 2015/10/08
- [Qemu-devel] [PULL 09/13] linux-user: Return target error number in do_fork(), riku . voipio, 2015/10/08
- [Qemu-devel] [PULL 11/13] linux-user/syscall.c: Add EAGAIN to host_to_target_errno_table for, riku . voipio, 2015/10/08
- [Qemu-devel] [PULL 12/13] linux-user/signal.c: Use setup_rt_frame() instead of setup_frame() for target openrisc, riku . voipio, 2015/10/08
- [Qemu-devel] [PULL 05/13] linux-user: Treat --foo options the same as -foo, riku . voipio, 2015/10/08
- [Qemu-devel] [PULL 13/13] linux-user: assert that target_mprotect cannot fail, riku . voipio, 2015/10/08
- [Qemu-devel] [PULL 01/13] linux-user: Exit 0 when -h is used, riku . voipio, 2015/10/08
- Re: [Qemu-devel] [PULL 00/13] linux-user queque, Peter Maydell, 2015/10/08
- [Qemu-devel] [PULL 02/13] linux-user: Add -help, riku . voipio, 2015/10/08
- [Qemu-devel] [PULL 03/13] linux-user: Add proper error messages for bad options,
riku . voipio <=
- [Qemu-devel] [PULL 07/13] linux-user: remove MAX_ARG_PAGES limit, riku . voipio, 2015/10/08
- [Qemu-devel] [PULL 08/13] linux-user: fix cmsg conversion in case of multiple headers, riku . voipio, 2015/10/08
- [Qemu-devel] [PULL 06/13] linux-user: remove unused image_info members, riku . voipio, 2015/10/08
- [Qemu-devel] [PULL 04/13] linux-user: use EXIT_SUCCESS and EXIT_FAILURE, riku . voipio, 2015/10/08