* [Qemu-devel] [PATCH] linux-user: Fix broken "-version" option
@ 2011-09-29 14:48 Peter Maydell
2011-10-13 11:04 ` Peter Maydell
2011-10-21 15:52 ` andrzej zaborowski
0 siblings, 2 replies; 3+ messages in thread
From: Peter Maydell @ 2011-09-29 14:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, patches
Fix the "-version" option, which was accidentally broken in commit
fc9c541:
* exit after printing version information rather than proceeding
blithely onward (and likely printing the full usage message)
* correct the cut-n-paste error in the usage message for it
* don't insist on the presence of a following argument for
options which don't take an argument (this was preventing
'qemu-arm -version' from working)
* remove a spurious argc check from the beginning of main() which
meant 'QEMU_VERSION=1 qemu-arm' didn't work.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
linux-user/main.c | 19 ++++++++-----------
1 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index 186358b..e7dad54 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -3084,6 +3084,7 @@ static void handle_arg_version(const char *arg)
{
printf("qemu-" TARGET_ARCH " version " QEMU_VERSION QEMU_PKGVERSION
", Copyright (c) 2003-2008 Fabrice Bellard\n");
+ exit(0);
}
struct qemu_argument {
@@ -3129,7 +3130,7 @@ struct qemu_argument arg_table[] = {
{"strace", "QEMU_STRACE", false, handle_arg_strace,
"", "log system calls"},
{"version", "QEMU_VERSION", false, handle_arg_version,
- "", "log system calls"},
+ "", "display version information and exit"},
{NULL, NULL, false, NULL, NULL, NULL}
};
@@ -3231,16 +3232,15 @@ static int parse_args(int argc, char **argv)
for (arginfo = arg_table; arginfo->handle_opt != NULL; arginfo++) {
if (!strcmp(r, arginfo->argv)) {
- if (optind >= argc) {
- usage();
- }
-
- arginfo->handle_opt(argv[optind]);
-
if (arginfo->has_arg) {
+ if (optind >= argc) {
+ usage();
+ }
+ arginfo->handle_opt(argv[optind]);
optind++;
+ } else {
+ arginfo->handle_opt(NULL);
}
-
break;
}
}
@@ -3276,9 +3276,6 @@ int main(int argc, char **argv, char **envp)
int i;
int ret;
- if (argc <= 1)
- usage();
-
qemu_cache_utils_init(envp);
if ((envlist = envlist_create()) == NULL) {
--
1.7.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: Fix broken "-version" option
2011-09-29 14:48 [Qemu-devel] [PATCH] linux-user: Fix broken "-version" option Peter Maydell
@ 2011-10-13 11:04 ` Peter Maydell
2011-10-21 15:52 ` andrzej zaborowski
1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2011-10-13 11:04 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, patches
Ping?
-- PMM
On 29 September 2011 15:48, Peter Maydell <peter.maydell@linaro.org> wrote:
> Fix the "-version" option, which was accidentally broken in commit
> fc9c541:
> * exit after printing version information rather than proceeding
> blithely onward (and likely printing the full usage message)
> * correct the cut-n-paste error in the usage message for it
> * don't insist on the presence of a following argument for
> options which don't take an argument (this was preventing
> 'qemu-arm -version' from working)
> * remove a spurious argc check from the beginning of main() which
> meant 'QEMU_VERSION=1 qemu-arm' didn't work.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> linux-user/main.c | 19 ++++++++-----------
> 1 files changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/linux-user/main.c b/linux-user/main.c
> index 186358b..e7dad54 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -3084,6 +3084,7 @@ static void handle_arg_version(const char *arg)
> {
> printf("qemu-" TARGET_ARCH " version " QEMU_VERSION QEMU_PKGVERSION
> ", Copyright (c) 2003-2008 Fabrice Bellard\n");
> + exit(0);
> }
>
> struct qemu_argument {
> @@ -3129,7 +3130,7 @@ struct qemu_argument arg_table[] = {
> {"strace", "QEMU_STRACE", false, handle_arg_strace,
> "", "log system calls"},
> {"version", "QEMU_VERSION", false, handle_arg_version,
> - "", "log system calls"},
> + "", "display version information and exit"},
> {NULL, NULL, false, NULL, NULL, NULL}
> };
>
> @@ -3231,16 +3232,15 @@ static int parse_args(int argc, char **argv)
>
> for (arginfo = arg_table; arginfo->handle_opt != NULL; arginfo++) {
> if (!strcmp(r, arginfo->argv)) {
> - if (optind >= argc) {
> - usage();
> - }
> -
> - arginfo->handle_opt(argv[optind]);
> -
> if (arginfo->has_arg) {
> + if (optind >= argc) {
> + usage();
> + }
> + arginfo->handle_opt(argv[optind]);
> optind++;
> + } else {
> + arginfo->handle_opt(NULL);
> }
> -
> break;
> }
> }
> @@ -3276,9 +3276,6 @@ int main(int argc, char **argv, char **envp)
> int i;
> int ret;
>
> - if (argc <= 1)
> - usage();
> -
> qemu_cache_utils_init(envp);
>
> if ((envlist = envlist_create()) == NULL) {
> --
> 1.7.4.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: Fix broken "-version" option
2011-09-29 14:48 [Qemu-devel] [PATCH] linux-user: Fix broken "-version" option Peter Maydell
2011-10-13 11:04 ` Peter Maydell
@ 2011-10-21 15:52 ` andrzej zaborowski
1 sibling, 0 replies; 3+ messages in thread
From: andrzej zaborowski @ 2011-10-21 15:52 UTC (permalink / raw)
To: Peter Maydell; +Cc: Riku Voipio, qemu-devel, patches
On 29 September 2011 16:48, Peter Maydell <peter.maydell@linaro.org> wrote:
> Fix the "-version" option, which was accidentally broken in commit
> fc9c541:
> * exit after printing version information rather than proceeding
> blithely onward (and likely printing the full usage message)
> * correct the cut-n-paste error in the usage message for it
> * don't insist on the presence of a following argument for
> options which don't take an argument (this was preventing
> 'qemu-arm -version' from working)
> * remove a spurious argc check from the beginning of main() which
> meant 'QEMU_VERSION=1 qemu-arm' didn't work.
Thanks, I pushed this patch.
Cheers
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-10-21 15:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-29 14:48 [Qemu-devel] [PATCH] linux-user: Fix broken "-version" option Peter Maydell
2011-10-13 11:04 ` Peter Maydell
2011-10-21 15:52 ` andrzej zaborowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).