From nobody Thu Nov 13 23:38:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253370; cv=none; d=zohomail.com; s=zohoarc; b=PhiBXBR7lKUmcS9AVp9tTdzsIE77nXYINXcpY4ly7NA4i1dcI14WuF+i9TBqBeV6Q46VGRxPQ5ijwzpbXd8TCpMcCedh7EOlXw4gw8pM5oxaU9ePnxjzH2JG3cmTtyo9YZVO8jcnXRwkHblseBtbBB7lzVg1ifH5dJDoLatrl4I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253370; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rbSWSFCqRg7Dyhwyu1gGZIgG7CVGvmA7JcPtABc7N4A=; b=lSFw7u0DzNAv6eqO921nGvtDoJ4sZC4fbxGhjOCO8aN9QFLz6tMEY6RhitDDXUIfc7wZ58KCLL172ewvB5LJxxbiTUY6zT826uyENErPEHo4pJpHPMFNf6PhRB36kKSHJY0Z7VWKKR5/WU7O8zlBkhqn7Y4+biE45OPdlZ6ST5Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 158325337044798.21260383823437; Tue, 3 Mar 2020 08:36:10 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-344-Os95FDorPUSSUkg15wGdAQ-1; Tue, 03 Mar 2020 11:36:05 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 379E41005513; Tue, 3 Mar 2020 16:35:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F10D61001B2C; Tue, 3 Mar 2020 16:35:58 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8019086A1C; Tue, 3 Mar 2020 16:35:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZEUR001273 for ; Tue, 3 Mar 2020 11:35:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id E33895DA82; Tue, 3 Mar 2020 16:35:14 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A90335DA2C; Tue, 3 Mar 2020 16:35:14 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 050D511329FF; Tue, 3 Mar 2020 17:35:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253369; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=rbSWSFCqRg7Dyhwyu1gGZIgG7CVGvmA7JcPtABc7N4A=; b=SrsblZFGKkBVwuzKgBL5YKEjUCO24S93DPaqF+SXZZ5UnW5YXB9TytQ/X8X1ukj61MrbKB Uuk72TXlpbeDz/lM97UeHecgJfN1AIQyd1iT5kI1DKmqshybg0eAPuE9sHJ1DBflcT4Z1i z3Tsq606QUjxHNkWV1EJ4aZccNmOSHU= X-MC-Unique: Os95FDorPUSSUkg15wGdAQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 22/30] qapi: Simplify how qmp_dispatch() deals with QCO_NO_SUCCESS_RESP Date: Tue, 3 Mar 2020 17:34:57 +0100 Message-Id: <20200303163505.32041-23-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster --- qapi/qmp-dispatch.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index a588072523..550d1fe8d2 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -106,7 +106,7 @@ QDict *qmp_dispatch(QmpCommandList *cmds, QObject *requ= est, QDict *dict =3D qobject_to(QDict, request); QObject *id =3D dict ? qdict_get(dict, "id") : NULL; QObject *ret =3D NULL; - QDict *rsp; + QDict *rsp =3D NULL; =20 dict =3D qmp_dispatch_check_obj(request, allow_oob, &err); if (!dict) { @@ -151,31 +151,32 @@ QDict *qmp_dispatch(QmpCommandList *cmds, QObject *re= quest, args =3D qdict_get_qdict(dict, "arguments"); qobject_ref(args); } - cmd->fn(args, &ret, &err); + qobject_unref(args); if (err) { - ; - } else if (cmd->options & QCO_NO_SUCCESS_RESP) { + goto out; + } + + if (cmd->options & QCO_NO_SUCCESS_RESP) { g_assert(!ret); + return NULL; } else if (!ret) { /* TODO turn into assertion */ ret =3D QOBJECT(qdict_new()); } =20 - qobject_unref(args); + rsp =3D qdict_new(); + qdict_put_obj(rsp, "return", ret); =20 out: if (err) { + assert(!rsp); rsp =3D qmp_error_response(err); - } else if (ret) { - rsp =3D qdict_new(); - qdict_put_obj(rsp, "return", ret); - } else { - /* Can only happen for commands with QCO_NO_SUCCESS_RESP */ - rsp =3D NULL; } =20 - if (rsp && id) { + assert(rsp); + + if (id) { qdict_put_obj(rsp, "id", qobject_ref(id)); } =20 --=20 2.21.1