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: 116964 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B2D0F1007D4 for ; Fri, 30 Sep 2011 00:48:32 +1000 (EST) Received: from localhost ([::1]:52949 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9HuW-0002yA-Ms for incoming@patchwork.ozlabs.org; Thu, 29 Sep 2011 10:48:28 -0400 Received: from eggs.gnu.org ([140.186.70.92]:46552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9HuQ-0002xz-Tg for qemu-devel@nongnu.org; Thu, 29 Sep 2011 10:48:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R9HuK-000179-3h for qemu-devel@nongnu.org; Thu, 29 Sep 2011 10:48:22 -0400 Received: from mnementh.archaic.org.uk ([81.2.115.146]:47987) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9HuJ-00016q-TP for qemu-devel@nongnu.org; Thu, 29 Sep 2011 10:48:16 -0400 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 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 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 81.2.115.146 Cc: Riku Voipio , patches@linaro.org Subject: [Qemu-devel] [PATCH] linux-user: Fix broken "-version" option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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) {