From patchwork Thu Sep 29 14:48:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 4439 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 4EF8B23F6E for ; Thu, 29 Sep 2011 14:48:18 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 35396A1818F for ; Thu, 29 Sep 2011 14:48:18 +0000 (UTC) Received: by fxe23 with SMTP id 23so2637850fxe.11 for ; Thu, 29 Sep 2011 07:48:18 -0700 (PDT) Received: by 10.223.63.8 with SMTP id z8mr3818907fah.84.1317307698002; Thu, 29 Sep 2011 07:48:18 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.3.234 with SMTP id f10cs17121laf; Thu, 29 Sep 2011 07:48:17 -0700 (PDT) Received: by 10.213.15.207 with SMTP id l15mr3858541eba.71.1317307697190; Thu, 29 Sep 2011 07:48:17 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id t45si1487727weq.126.2011.09.29.07.48.16 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 29 Sep 2011 07:48:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1R9HuG-0006t9-2c; Thu, 29 Sep 2011 15:48:12 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: Riku Voipio , patches@linaro.org Subject: [PATCH] linux-user: Fix broken "-version" option Date: Thu, 29 Sep 2011 15:48:12 +0100 Message-Id: <1317307692-26456-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 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 --- 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) {