From patchwork Thu Jan 21 21:09:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 43458 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9C486B7CDA for ; Fri, 22 Jan 2010 08:30:36 +1100 (EST) Received: from localhost ([127.0.0.1]:45034 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NY4bJ-00020k-PS for incoming@patchwork.ozlabs.org; Thu, 21 Jan 2010 16:30:01 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NY4IU-00011v-35 for qemu-devel@nongnu.org; Thu, 21 Jan 2010 16:10:34 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NY4IP-0000uc-AL for qemu-devel@nongnu.org; Thu, 21 Jan 2010 16:10:33 -0500 Received: from [199.232.76.173] (port=43491 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NY4IP-0000uL-51 for qemu-devel@nongnu.org; Thu, 21 Jan 2010 16:10:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55051) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NY4IO-00033o-NQ for qemu-devel@nongnu.org; Thu, 21 Jan 2010 16:10:28 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0LLAR9E011041 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 21 Jan 2010 16:10:28 -0500 Received: from localhost (vpn-9-176.rdu.redhat.com [10.11.9.176]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o0LLAPc9016014; Thu, 21 Jan 2010 16:10:26 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org, armbru@redhat.com, aliguori@us.ibm.com, avi@redhat.com Date: Thu, 21 Jan 2010 19:09:38 -0200 Message-Id: <1264108180-3666-10-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1264108180-3666-1-git-send-email-lcapitulino@redhat.com> References: <1264108180-3666-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCH 09/11] Monitor: Introduce find_info_cmd() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Move the code used to locate an info command entry to its own function, as it's going to be used by other functions. Signed-off-by: Luiz Capitulino --- monitor.c | 21 +++++++++++++++------ 1 files changed, 15 insertions(+), 6 deletions(-) diff --git a/monitor.c b/monitor.c index 321bc3a..34df1cc 100644 --- a/monitor.c +++ b/monitor.c @@ -512,6 +512,19 @@ static void do_async_msg_disable(Monitor *mon, const QDict *qdict, qevent_set_value(mon, qdict, 0); } +static const mon_cmd_t *monitor_find_info_command(const char *name) +{ + const mon_cmd_t *cmd; + + for (cmd = info_cmds; cmd->name != NULL; cmd++) { + if (compare_cmd(name, cmd->name)) { + return cmd; + } + } + + return NULL; +} + static void do_info(Monitor *mon, const QDict *qdict, QObject **ret_data) { const mon_cmd_t *cmd; @@ -522,12 +535,8 @@ static void do_info(Monitor *mon, const QDict *qdict, QObject **ret_data) goto help; } - for (cmd = info_cmds; cmd->name != NULL; cmd++) { - if (compare_cmd(item, cmd->name)) - break; - } - - if (cmd->name == NULL) { + cmd = monitor_find_info_command(item); + if (!cmd) { if (monitor_ctrl_mode(mon)) { qemu_error_new(QERR_COMMAND_NOT_FOUND, item); return;