From patchwork Fri Feb 17 20:38:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 729352 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 3vQ5H00tzGz9s8W for ; Sat, 18 Feb 2017 08:08:44 +1100 (AEDT) Received: from localhost ([::1]:55972 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceplh-000687-HJ for incoming@patchwork.ozlabs.org; Fri, 17 Feb 2017 16:08:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58991) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cepIU-0002Yg-SU for qemu-devel@nongnu.org; Fri, 17 Feb 2017 15:38:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cepIT-0004QI-OL for qemu-devel@nongnu.org; Fri, 17 Feb 2017 15:38:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38898) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cepIT-0004PV-Hf for qemu-devel@nongnu.org; Fri, 17 Feb 2017 15:38:29 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A8F4861D2C for ; Fri, 17 Feb 2017 20:38:29 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1HKcSTL008001 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Fri, 17 Feb 2017 15:38:29 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 686F611384B9; Fri, 17 Feb 2017 21:38:25 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 17 Feb 2017 21:38:24 +0100 Message-Id: <1487363905-9480-14-git-send-email-armbru@redhat.com> In-Reply-To: <1487363905-9480-1-git-send-email-armbru@redhat.com> References: <1487363905-9480-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 17 Feb 2017 20:38:29 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 13/14] monitor: Clean up handle_hmp_command() a bit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Leave checking qobject_type(req) to qmp_check_input_obj(). Rework handling of json_parser_parse_err() failing without setting an error. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- monitor.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/monitor.c b/monitor.c index 493bed9..1e352a6 100644 --- a/monitor.c +++ b/monitor.c @@ -3735,10 +3735,11 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens) Error *err = NULL; req = json_parser_parse_err(tokens, NULL, &err); - if (err || !req || qobject_type(req) != QTYPE_QDICT) { - if (!err) { - error_setg(&err, QERR_JSON_PARSING); - } + if (!req && !err) { + /* json_parser_parse_err() sucks: can fail without setting @err */ + error_setg(&err, QERR_JSON_PARSING); + } + if (err) { goto err_out; }