From patchwork Tue Jun 2 08:23:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 479314 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7E9B71412E9 for ; Tue, 2 Jun 2015 18:24:54 +1000 (AEST) Received: from localhost ([::1]:56614 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzhVE-00033G-4P for incoming@patchwork.ozlabs.org; Tue, 02 Jun 2015 04:24:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34320) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzhUX-0001lh-0x for qemu-devel@nongnu.org; Tue, 02 Jun 2015 04:24:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YzhUR-0000fe-OX for qemu-devel@nongnu.org; Tue, 02 Jun 2015 04:24:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54989) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzhUR-0000fD-JC for qemu-devel@nongnu.org; Tue, 02 Jun 2015 04:24:03 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 81DD7CC7F5 for ; Tue, 2 Jun 2015 08:24:02 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t528O0J8000367 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 2 Jun 2015 04:24:01 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0A5103046036; Tue, 2 Jun 2015 10:24:00 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 2 Jun 2015 10:23:40 +0200 Message-Id: <1433233439-3386-3-git-send-email-armbru@redhat.com> In-Reply-To: <1433233439-3386-1-git-send-email-armbru@redhat.com> References: <1433233439-3386-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 02/21] monitor: Clean up after previous commit 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 Inline qmp_call_cmd() along with its helper handler_audit() into its only caller handle_qmp_command(), and simplify the result. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Luiz Capitulino --- monitor.c | 40 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/monitor.c b/monitor.c index 27efeb6..416ba10 100644 --- a/monitor.c +++ b/monitor.c @@ -4045,18 +4045,6 @@ void monitor_set_error(Monitor *mon, QError *qerror) } } -static void handler_audit(Monitor *mon, const mon_cmd_t *cmd, int ret) -{ - if (ret && !monitor_has_error(mon)) { - /* - * If it returns failure, it must have passed on error. - * - * Action: Report an internal error to the client if in QMP. - */ - qerror_report(QERR_UNDEFINED_ERROR); - } -} - static void handle_user_command(Monitor *mon, const char *cmdline) { QDict *qdict; @@ -5013,28 +5001,17 @@ static QDict *qmp_check_input_obj(QObject *input_obj) return input_dict; } -static void qmp_call_cmd(Monitor *mon, const mon_cmd_t *cmd, - const QDict *params) -{ - int ret; - QObject *data = NULL; - - ret = cmd->mhandler.cmd_new(mon, params, &data); - handler_audit(mon, cmd, ret); - monitor_protocol_emitter(mon, data); - qobject_decref(data); -} - static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) { int err; - QObject *obj; + QObject *obj, *data; QDict *input, *args; const mon_cmd_t *cmd; const char *cmd_name; Monitor *mon = cur_mon; args = input = NULL; + data = NULL; obj = json_parser_parse(tokens, NULL); if (!obj) { @@ -5077,12 +5054,17 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) goto err_out; } - qmp_call_cmd(mon, cmd, args); - goto out; + if (cmd->mhandler.cmd_new(mon, args, &data)) { + /* Command failed... */ + if (!monitor_has_error(mon)) { + /* ... without setting an error, so make one up */ + qerror_report(QERR_UNDEFINED_ERROR); + } + } err_out: - monitor_protocol_emitter(mon, NULL); -out: + monitor_protocol_emitter(mon, data); + qobject_decref(data); QDECREF(input); QDECREF(args); }