@@ -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;
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 <lcapitulino@redhat.com> --- monitor.c | 21 +++++++++++++++------ 1 files changed, 15 insertions(+), 6 deletions(-)