[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 6/8] Monitor: Introduce find_info_cmd()
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 6/8] Monitor: Introduce find_info_cmd() |
Date: |
Thu, 28 Jan 2010 11:42:58 -0200 |
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 <address@hidden>
---
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
- [Qemu-devel] [PATCH 0/8]: QMP feature negotiation support, Luiz Capitulino, 2010/01/28
- [Qemu-devel] [PATCH 1/8] QMP: Initial mode-oriented support, Luiz Capitulino, 2010/01/28
- [Qemu-devel] [PATCH 2/8] QMP: Introduce 'query-qmp-mode' command, Luiz Capitulino, 2010/01/28
- [Qemu-devel] [PATCH 3/8] QError: Add QMP mode-oriented errors, Luiz Capitulino, 2010/01/28
- [Qemu-devel] [PATCH 4/8] QMP: Introduce qmp_switch_mode command, Luiz Capitulino, 2010/01/28
- [Qemu-devel] [PATCH 5/8] QMP: Introduce qmp_capability_enable/disable, Luiz Capitulino, 2010/01/28
- [Qemu-devel] [PATCH 7/8] QMP: Enable feature negotiation support, Luiz Capitulino, 2010/01/28
- [Qemu-devel] [PATCH 6/8] Monitor: Introduce find_info_cmd(),
Luiz Capitulino <=
- [Qemu-devel] [PATCH 8/8] QMP: spec: Feature negotiation related changes, Luiz Capitulino, 2010/01/28