Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NaUek-0000Nu-7c for qemu-devel@nongnu.org; Thu, 28 Jan 2010 08:43:34 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NaUed-0000Km-8Y for qemu-devel@nongnu.org; Thu, 28 Jan 2010 08:43:32 -0500 Received: from [199.232.76.173] (port=57173 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NaUec-0000Kh-QE for qemu-devel@nongnu.org; Thu, 28 Jan 2010 08:43:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36494) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NaUec-0003yf-3h for qemu-devel@nongnu.org; Thu, 28 Jan 2010 08:43:26 -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 o0SDhPoT022043 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 28 Jan 2010 08:43:25 -0500 Received: from localhost (vpn-10-249.rdu.redhat.com [10.11.10.249]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o0SDhNKQ028295 for ; Thu, 28 Jan 2010 08:43:24 -0500 From: Luiz Capitulino Date: Thu, 28 Jan 2010 11:42:58 -0200 Message-Id: <1264686180-29845-7-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1264686180-29845-1-git-send-email-lcapitulino@redhat.com> References: <1264686180-29845-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [PATCH 6/8] Monitor: Introduce find_info_cmd() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@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 9070a0c..5851b6d 100644 --- a/monitor.c +++ b/monitor.c @@ -538,6 +538,19 @@ static void user_async_info_handler(Monitor *mon, const mon_cmd_t *cmd) } } +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; @@ -548,12 +561,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; -- 1.6.6