From nobody Mon Feb 9 01:00:11 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587658018; cv=none; d=zohomail.com; s=zohoarc; b=WNrAjxUBwGZBnoEICIhl0FdB5GSfEw8wgSIMrD/Y9Vf5bjhWfmufgOZJ09mBiLaUEpM+QYbiKSkczdj2cSeBR3qFlBnB9qpQqFLu2rqO+81j4vfIyVYiKIsGEj4u5Bbbz3NfruIfhd5rTCawr8QukWruPCMjqgEvbKy2cWcp9DU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587658018; 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=AorLotF1j7RvB12PFYX5lxGkv3DttGRrYNfU+YHZZZg=; b=UpJ3c8L3P8FJr9jE3MKHtZbF/5OuMW63BCy8pgBC7DkA8PNQD6O2D11hY6ael1++7Rgd3BoDHrH+9i/ja+vXRMJh3bYHaHMvcnrCJvStGXPj+ZZv9WxnIcpi7uES+Y9/6NJoXitxm1rugPh7kThIYncLOmGFcjBChoLg0fHfV/Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587658018919344.5940205419863; Thu, 23 Apr 2020 09:06:58 -0700 (PDT) Received: from localhost ([::1]:57972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReNN-00063Q-83 for importer@patchew.org; Thu, 23 Apr 2020 12:06:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59882) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReHk-00063G-OX for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jReHQ-00022u-Jw for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:08 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:30683 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jReHQ-0001wp-2T for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:00:48 -0400 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-509-XuheM1CpN7KzkaZ0w8P_pQ-1; Thu, 23 Apr 2020 12:00:39 -0400 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 242BD180F105; Thu, 23 Apr 2020 16:00:38 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E218810016EB; Thu, 23 Apr 2020 16:00:37 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 574A211358BD; Thu, 23 Apr 2020 18:00:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587657641; h=from:from: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; bh=AorLotF1j7RvB12PFYX5lxGkv3DttGRrYNfU+YHZZZg=; b=JCIAFKbTbq9t3sVN+hSP/l6IYtpFCRPBZp34sTjSln3Tt9nKxZdvZtFUoI1G2DMg93chUX R2nAuKFo5zND1POeRwYV4fXtJfj5V4z7TxwYURPGcqkFE3f1HcSM4u9RqFx+/SZvngBwzE w/12bCDYomu2GUwQd9cxiWe/xNjAuwU= X-MC-Unique: XuheM1CpN7KzkaZ0w8P_pQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 01/13] qapi: Belatedly update visitor.h's big comment for QAPI modules Date: Thu, 23 Apr 2020 18:00:24 +0200 Message-Id: <20200423160036.7048-2-armbru@redhat.com> In-Reply-To: <20200423160036.7048-1-armbru@redhat.com> References: <20200423160036.7048-1-armbru@redhat.com> MIME-Version: 1.0 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 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/23 02:14:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- include/qapi/visitor.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index c5b23851a1..f8a0fc1ea9 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -58,7 +58,7 @@ * * where T is FOO for scalar types, and FOO * otherwise. The scalar * visitors are declared here; the remaining visitors are generated in - * qapi-visit.h. + * qapi-visit-MODULE.h. * * The @name parameter of visit_type_FOO() describes the relation * between this QAPI value and its parent container. When visiting @@ -86,16 +86,16 @@ * by manual construction. * * For the QAPI object types (structs, unions, and alternates), there - * is an additional generated function in qapi-visit.h compatible - * with: + * is an additional generated function in qapi-visit-MODULE.h + * compatible with: * * void visit_type_FOO_members(Visitor *v, FOO *obj, Error **errp); * * for visiting the members of a type without also allocating the QAPI * struct. * - * Additionally, in qapi-types.h, all QAPI pointer types (structs, - * unions, alternates, and lists) have a generated function compatible + * Additionally, QAPI pointer types (structs, unions, alternates, and + * lists) have a generated function in qapi-types-MODULE.h compatible * with: * * void qapi_free_FOO(FOO *obj); --=20 2.21.1 From nobody Mon Feb 9 01:00:11 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587658202; cv=none; d=zohomail.com; s=zohoarc; b=WhXPHm+5OoWVDODSW9NIqxKmpsRC5JBG7B2Q1i6H9e+TW7fYnwD8iEMF7Bm+aN/PTiP42MArkJysJQz6H/nagM9E/sip2XzV0ZqcGE9uVEG04ezYkhmZQnhYz48moIzAE6b3IV4PzoHLicV4Yzwhw7IbJDje5UnHacBcQQjMkm8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587658202; 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=82PBqwMiQDZXhV2FxXh59m2D3DaX5boDh8uZPfq8DfY=; b=gIDj//cbbLDMPz0XnF0JHX+btnEkv5a7Tc0Lfd9+3UXCMe4QtgcEdIjWbFvrnL5NlKegjuSnnQC3JThlwNFNqrCLdNvF4UWsaO2l8svQmGiUljxcCEmEz4nfp6qoRAkExAmg0x7V0yfRihT4Vcfpa72X9h++xXpp0ProYjuP8F4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587658202707228.5979038240281; Thu, 23 Apr 2020 09:10:02 -0700 (PDT) Received: from localhost ([::1]:58258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReQL-0004Vz-BJ for importer@patchew.org; Thu, 23 Apr 2020 12:10:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59908) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReHn-00064X-A7 for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jReHT-00026E-Is for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:11 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:27484 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jReHS-000228-1l for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:00:50 -0400 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-77-bMrfp-0gPOqFUQp1yNm6ig-1; Thu, 23 Apr 2020 12:00:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 285AB107ACF4; Thu, 23 Apr 2020 16:00:38 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E81685D714; Thu, 23 Apr 2020 16:00:37 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5A2F811358BE; Thu, 23 Apr 2020 18:00:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587657646; h=from:from: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; bh=82PBqwMiQDZXhV2FxXh59m2D3DaX5boDh8uZPfq8DfY=; b=bmqZZvuzVbP+p6aDzNPaWnMnmzU2uKfa49/1DKW1fwfLoEAZjEQuMtTxg630sipC8nwQUy 9FVkbstHLXjPiaALqlnL446+8nPst++rEOHswkhFAjCwfnfoIX6lSAuUrsnOTZAkL/P0lv NWNxPecP3RW9yZ/eMcdbb6CpQyhGlXo= X-MC-Unique: bMrfp-0gPOqFUQp1yNm6ig-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 02/13] qapi: Fix the virtual walk example in visitor.h's big comment Date: Thu, 23 Apr 2020 18:00:25 +0200 Message-Id: <20200423160036.7048-3-armbru@redhat.com> In-Reply-To: <20200423160036.7048-1-armbru@redhat.com> References: <20200423160036.7048-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/23 02:14:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Call visit_check_list(). Missed in commit a4a1c70dc7 "qapi: Make input visitors detect unvisited list tails". Drop an irrelevant error_propagate() while there. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- include/qapi/visitor.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index f8a0fc1ea9..7f63e4c381 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -215,6 +215,9 @@ * goto outlist; * } * outlist: + * if (!err) { + * visit_check_list(v, &err); + * } * visit_end_list(v, NULL); * if (!err) { * visit_check_struct(v, &err); @@ -222,7 +225,6 @@ * outobj: * visit_end_struct(v, NULL); * out: - * error_propagate(errp, err); * visit_free(v); * */ --=20 2.21.1 From nobody Mon Feb 9 01:00:11 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587658109; cv=none; d=zohomail.com; s=zohoarc; b=Qy/CG5al5SIbp9UVU7o64DvFsYPBkDOHAVOWXu6pz6C7tnqPn9sBHOGYhr0h+d9TXB3XQnHFQGetipJNM9QVKg2EZ/T3wouaPeRMzUPnkFDLUtMsroezjvYTt6E0eaRHndQfF6VZQeNwF5bqqum7hmAcLUTKL6hfXqvelTr/heg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587658109; 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=mDIuVuNGP9U1znFRvNxfe9I5PKzD+02dNqwuJis8ezs=; b=dp9PkTHSACoxe24/efFvNpfeWDPsRsqHpTewdkdSBs6v8K972yesBQrQvaYuG9/NBSx2tAeSte1HAV8i7oxoT3TCNWFs0vuVAj/woj5+QgPaK2ECm2ko6I4u9VM/8qI4/57fvhJTEru+f4TS+f9q3pUy67SWFpl9aD0nC1zt4NI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587658109381531.7586232233826; Thu, 23 Apr 2020 09:08:29 -0700 (PDT) Received: from localhost ([::1]:58098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReOp-00011E-Pq for importer@patchew.org; Thu, 23 Apr 2020 12:08:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59880) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReHl-00063F-NF for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jReHQ-00022z-K0 for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:08 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:37979 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jReHQ-0001yX-2W for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:00:48 -0400 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-341-NPLc0572Om-8IiNHh-QUSQ-1; Thu, 23 Apr 2020 12:00:39 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3FE6F8014D5; Thu, 23 Apr 2020 16:00:38 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EDA3D196AE; Thu, 23 Apr 2020 16:00:37 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5D68011358BF; Thu, 23 Apr 2020 18:00:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587657641; h=from:from: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; bh=mDIuVuNGP9U1znFRvNxfe9I5PKzD+02dNqwuJis8ezs=; b=aIVvBiQ+HjSZkhLeoRbLAHKGdn3d/nHC+EZLstSGZ90mqrBR4JvijIP1qXPlcYlTBCljWu p0mA90QBN4B4PnJ5kDWPWSXoUoDvtanYG49rBppsZKdP7MLCtigcW4ulCew/jz5NhGuCDW Gh/tQh77GgOcwZH3yD0/HWYoVhtX3qU= X-MC-Unique: NPLc0572Om-8IiNHh-QUSQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 03/13] qapi: Fix typo in visit_start_list()'s contract Date: Thu, 23 Apr 2020 18:00:26 +0200 Message-Id: <20200423160036.7048-4-armbru@redhat.com> In-Reply-To: <20200423160036.7048-1-armbru@redhat.com> References: <20200423160036.7048-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/23 02:14:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- include/qapi/visitor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index 7f63e4c381..c5d0ce9184 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -345,9 +345,9 @@ void visit_end_struct(Visitor *v, void **obj); * input visitors set *@list to NULL. * * After visit_start_list() succeeds, the caller may visit its members - * one after the other. A real visit (where @obj is non-NULL) uses + * one after the other. A real visit (where @list is non-NULL) uses * visit_next_list() for traversing the linked list, while a virtual - * visit (where @obj is NULL) uses other means. For each list + * visit (where @list is NULL) uses other means. For each list * element, call the appropriate visit_type_FOO() with name set to * NULL and obj set to the address of the value member of the list * element. Finally, visit_end_list() needs to be called with the --=20 2.21.1 From nobody Mon Feb 9 01:00:11 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587658308; cv=none; d=zohomail.com; s=zohoarc; b=kbmO89eVFJqev78nqObjO1R1LyZqtnlwEutqUWyOyh/YAsipRWZCuiO/S42ZjI/IJmTPT1N35cFcUai8mch1A6+tjrH6N2SVa6Ssyci5+qhAwcKkRhry0piI4JfxfC2TYKFLFVkXM55tcaquOnKiMaoPU4msvTnic1WB6tYmGvc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587658308; 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=NL1iSgHrvz10Q9W3PP0K81rICAw1IKYoa6kbpW3UVEY=; b=ECAU43qFtuU3JzMHpvQQoXpXeAdXQ8GI4dhvOoSpYn/HdLWRzTw/CGIJWMDATVuAhfAx2NHF/RNfdyX5CUZATg5DXljBNBEwpGZWcoL4Avqx/EYkM+8jbsPwRwCDHoNA5umoLWH5uCq3leMLJHTovl/ERKQuhP+Exb/Mn3t6ntg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587658308431995.4541307506785; Thu, 23 Apr 2020 09:11:48 -0700 (PDT) Received: from localhost ([::1]:58476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReS2-0007aO-Uj for importer@patchew.org; Thu, 23 Apr 2020 12:11:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59928) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReHo-00066d-E8 for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jReHX-0002Az-SF for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:12 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:22280 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jReHT-00021z-6n for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:00:51 -0400 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-337-jeT99QcjOtKu6aGgB8n3dA-1; Thu, 23 Apr 2020 12:00:41 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 93B7E107ACF9; Thu, 23 Apr 2020 16:00:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D3C860621; Thu, 23 Apr 2020 16:00:38 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 60AEC11358C0; Thu, 23 Apr 2020 18:00:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587657645; h=from:from: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; bh=NL1iSgHrvz10Q9W3PP0K81rICAw1IKYoa6kbpW3UVEY=; b=aez+6Id7OJ8pGM53KpWzFhlk1+X+jYsyCeHbchW6BbeM8iAD7eUyuiiqzU9G8vuES5VmLL 1hLkRrkjhytZe/GN633l41XCfKsmB19F0t1ie2EK6LLJgRfbeg6zmgw3STNG8uqAWyvs+2 IjGrOOmaEuuvTl1gVnDyN+qnQeF0pr4= X-MC-Unique: jeT99QcjOtKu6aGgB8n3dA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 04/13] qapi: Document @errp usage more thoroughly in visitor.h Date: Thu, 23 Apr 2020 18:00:27 +0200 Message-Id: <20200423160036.7048-5-armbru@redhat.com> In-Reply-To: <20200423160036.7048-1-armbru@redhat.com> References: <20200423160036.7048-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/23 02:14:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- include/qapi/visitor.h | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index c5d0ce9184..09df7099c6 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -284,9 +284,7 @@ void visit_free(Visitor *v); * into *@obj. @obj may also be NULL for a virtual walk, in which * case @size is ignored. * - * @errp obeys typical error usage, and reports failures such as a - * member @name is not present, or present but not an object. On - * error, input visitors set *@obj to NULL. + * On failure, set *@obj to NULL and store an error through @errp. * * After visit_start_struct() succeeds, the caller may visit its * members one after the other, passing the member's name and address @@ -303,8 +301,7 @@ void visit_start_struct(Visitor *v, const char *name, v= oid **obj, /* * Prepare for completing an object visit. * - * @errp obeys typical error usage, and reports failures such as - * unparsed keys remaining in the input stream. + * On failure, store an error through @errp. * * Should be called prior to visit_end_struct() if all other * intermediate visit steps were successful, to allow the visitor one @@ -340,9 +337,7 @@ void visit_end_struct(Visitor *v, void **obj); * allow @list to be NULL for a virtual walk, in which case @size is * ignored. * - * @errp obeys typical error usage, and reports failures such as a - * member @name is not present, or present but not a list. On error, - * input visitors set *@list to NULL. + * On failure, set *@list to NULL and store an error through @errp. * * After visit_start_list() succeeds, the caller may visit its members * one after the other. A real visit (where @list is non-NULL) uses @@ -376,8 +371,7 @@ GenericList *visit_next_list(Visitor *v, GenericList *t= ail, size_t size); /* * Prepare for completing a list visit. * - * @errp obeys typical error usage, and reports failures such as - * unvisited list tail remaining in the input stream. + * On failure, store an error through @errp. * * Should be called prior to visit_end_list() if all other * intermediate visit steps were successful, to allow the visitor one @@ -409,8 +403,10 @@ void visit_end_list(Visitor *v, void **list); * * @obj must not be NULL. Input and clone visitors use @size to * determine how much memory to allocate into *@obj, then determine - * the qtype of the next thing to be visited, stored in (*@obj)->type. - * Other visitors will leave @obj unchanged. + * the qtype of the next thing to be visited, and store it in + * (*@obj)->type. Other visitors leave @obj unchanged. + * + * On failure, set *@obj to NULL and store an error through @errp. * * If successful, this must be paired with visit_end_alternate() with * the same @obj to clean up, even if visiting the contents of the @@ -463,8 +459,9 @@ bool visit_optional(Visitor *v, const char *name, bool = *present); * * Currently, all input visitors parse text input, and all output * visitors produce text output. The mapping between enumeration - * values and strings is done by the visitor core, using @strings; it - * should be the ENUM_lookup array from visit-types.h. + * values and strings is done by the visitor core, using @lookup. + * + * On failure, store an error through @errp. * * May call visit_type_str() under the hood, and the enum visit may * fail even if the corresponding string visit succeeded; this implies @@ -488,6 +485,8 @@ bool visit_is_input(Visitor *v); * * @obj must be non-NULL. Input visitors set *@obj to the value; * other visitors will leave *@obj unchanged. + * + * On failure, store an error through @errp. */ void visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **er= rp); =20 @@ -564,6 +563,8 @@ void visit_type_size(Visitor *v, const char *name, uint= 64_t *obj, * * @obj must be non-NULL. Input visitors set *@obj to the value; * other visitors will leave *@obj unchanged. + * + * On failure, store an error through @errp. */ void visit_type_bool(Visitor *v, const char *name, bool *obj, Error **errp= ); =20 @@ -581,6 +582,8 @@ void visit_type_bool(Visitor *v, const char *name, bool= *obj, Error **errp); * It is safe to cast away const when preparing a (const char *) value * into @obj for use by an output visitor. * + * On failure, set *@obj to NULL and store an error through @errp. + * * FIXME: Callers that try to output NULL *obj should not be allowed. */ void visit_type_str(Visitor *v, const char *name, char **obj, Error **errp= ); @@ -594,6 +597,8 @@ void visit_type_str(Visitor *v, const char *name, char = **obj, Error **errp); * @obj must be non-NULL. Input visitors set *@obj to the value; * other visitors will leave *@obj unchanged. Visitors should * document if infinity or NaN are not permitted. + * + * On failure, store an error through @errp. */ void visit_type_number(Visitor *v, const char *name, double *obj, Error **errp); @@ -608,6 +613,8 @@ void visit_type_number(Visitor *v, const char *name, do= uble *obj, * other visitors will leave *@obj unchanged. *@obj must be non-NULL * for output visitors. * + * On failure, set *@obj to NULL and store an error through @errp. + * * Note that some kinds of input can't express arbitrary QObject. * E.g. the visitor returned by qobject_input_visitor_new_keyval() * can't create numbers or booleans, only strings. @@ -622,6 +629,8 @@ void visit_type_any(Visitor *v, const char *name, QObje= ct **obj, Error **errp); * * @obj must be non-NULL. Input visitors set *@obj to the value; * other visitors ignore *@obj. + * + * On failure, set *@obj to NULL and store an error through @errp. */ void visit_type_null(Visitor *v, const char *name, QNull **obj, Error **errp); --=20 2.21.1 From nobody Mon Feb 9 01:00:11 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587658117; cv=none; d=zohomail.com; s=zohoarc; b=ASQmymYybVlDhtl6abE+vH+ikf1i17v7q+TmPnptYc2ZjoA8ZlW8fN7sR4A/vVrVB5Aljv5ULk9fG5453iafvEk/uZUmzIdeN0xF3wUrx4TNfm4jDxqIIoL1umoMlG2ysu9IacV4gqbKfCGBgA2Te/wgoa57TtA6TaeibVwNMNU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587658117; 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=uoSl0XZT4ewXVJQJK65d19tmvTgXmgzq+a7IR/Bw1g0=; b=O+IC0WUVdElykttXGo74Csd+ZXUzt9d4o8MwYBtPeA+4zPxcPQQalHGB/0uJMidl6QTzjEYzyvJ+SguxcAo3rimfkB0qYT5UKyhA8lSPiuZqlStXcVLygRhQDV8eebTUQilcsLosgSLTdG+0JDM6uSeMCrCfMSIwfdj9u1WBN7g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15876581178401022.3550501120113; Thu, 23 Apr 2020 09:08:37 -0700 (PDT) Received: from localhost ([::1]:58122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReOy-0001PP-D7 for importer@patchew.org; Thu, 23 Apr 2020 12:08:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59920) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReHn-00065L-Ny for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jReHT-000264-Hl for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:11 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:59907 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jReHS-00021w-1Q for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:00:50 -0400 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-387-_AFaT-McN6mWMMu78Ejuiw-1; Thu, 23 Apr 2020 12:00:40 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D2C6A460; Thu, 23 Apr 2020 16:00:39 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 76A496109F; Thu, 23 Apr 2020 16:00:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 63E5711358C1; Thu, 23 Apr 2020 18:00:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587657645; h=from:from: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; bh=uoSl0XZT4ewXVJQJK65d19tmvTgXmgzq+a7IR/Bw1g0=; b=dDzRG3QvgAp3TwuN77EOe9SjPbD9shbJeRB7udjTaAnyrMN/6xaPW50EVn7zwSnSOkr2Bj TFwViUaQA2Bwk3LfU+xQPGYBQr8cXPdyIYqXSZ/s9Ku85BvwHxVK1+V46ffbNDlAtzElmR Onb+hiaYFtXVhvNMCKR+Kw8bq/40uLE= X-MC-Unique: _AFaT-McN6mWMMu78Ejuiw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 05/13] qapi: Polish prose in visitor.h Date: Thu, 23 Apr 2020 18:00:28 +0200 Message-Id: <20200423160036.7048-6-armbru@redhat.com> In-Reply-To: <20200423160036.7048-1-armbru@redhat.com> References: <20200423160036.7048-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/23 02:14:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- include/qapi/visitor.h | 104 +++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 50 deletions(-) diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index 09df7099c6..a425ea514c 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -25,19 +25,21 @@ * for doing work at each node of a QAPI graph; it can also be used * for a virtual walk, where there is no actual QAPI C struct. * - * There are four kinds of visitor classes: input visitors (QObject, - * string, and QemuOpts) parse an external representation and build - * the corresponding QAPI graph, output visitors (QObject and string) take - * a completed QAPI graph and generate an external representation, the - * dealloc visitor can take a QAPI graph (possibly partially - * constructed) and recursively free its resources, and the clone - * visitor performs a deep clone of one QAPI object to another. While - * the dealloc and QObject input/output visitors are general, the string, - * QemuOpts, and clone visitors have some implementation limitations; - * see the documentation for each visitor for more details on what it - * supports. Also, see visitor-impl.h for the callback contracts - * implemented by each visitor, and docs/devel/qapi-code-gen.txt for more - * about the QAPI code generator. + * There are four kinds of visitors: input visitors (QObject, string, + * and QemuOpts) parse an external representation and build the + * corresponding QAPI object, output visitors (QObject and string) + * take a QAPI object and generate an external representation, the + * dealloc visitor takes a QAPI object (possibly partially + * constructed) and recursively frees it, and the clone visitor + * performs a deep clone of a QAPI object. + * + * While the dealloc and QObject input/output visitors are general, + * the string, QemuOpts, and clone visitors have some implementation + * limitations; see the documentation for each visitor for more + * details on what it supports. Also, see visitor-impl.h for the + * callback contracts implemented by each visitor, and + * docs/devel/qapi-code-gen.txt for more about the QAPI code + * generator. * * All of the visitors are created via: * @@ -45,11 +47,15 @@ * * A visitor should be used for exactly one top-level visit_type_FOO() * or virtual walk; if that is successful, the caller can optionally - * call visit_complete() (for now, useful only for output visits, but - * safe to call on all visits). Then, regardless of success or - * failure, the user should call visit_free() to clean up resources. - * It is okay to free the visitor without completing the visit, if - * some other error is detected in the meantime. + * call visit_complete() (useful only for output visits, but safe to + * call on all visits). Then, regardless of success or failure, the + * user should call visit_free() to clean up resources. It is okay to + * free the visitor without completing the visit, if some other error + * is detected in the meantime. + * + * The clone and dealloc visitor should not be used directly outside + * of QAPI code. Use the qapi_free_FOO() and QAPI_CLONE() instead, + * described below. * * All QAPI types have a corresponding function with a signature * roughly compatible with this: @@ -68,22 +74,26 @@ * alternate, @name should equal the name used for visiting the * alternate. * - * The visit_type_FOO() functions expect a non-null @obj argument; - * they allocate *@obj during input visits, leave it unchanged on - * output visits, and recursively free any resources during a dealloc - * visit. Each function also takes the customary @errp argument (see + * The visit_type_FOO() functions take a non-null @obj argument; they + * allocate *@obj during input visits, leave it unchanged during + * output and clone visits, and free it (recursively) during a dealloc + * visit. + * + * Each function also takes the customary @errp argument (see * qapi/error.h for details), for reporting any errors (such as if a * member @name is not present, or is present but not the specified * type). * * If an error is detected during visit_type_FOO() with an input - * visitor, then *@obj will be NULL for pointer types, and left - * unchanged for scalar types. Using an output or clone visitor with - * an incomplete object has undefined behavior (other than a special - * case for visit_type_str() treating NULL like ""), while the dealloc - * visitor safely handles incomplete objects. Since input visitors - * never produce an incomplete object, such an object is possible only - * by manual construction. + * visitor, then *@obj will be set to NULL for pointer types, and left + * unchanged for scalar types. + * + * Using an output or clone visitor with an incomplete object has + * undefined behavior (other than a special case for visit_type_str() + * treating NULL like ""), while the dealloc visitor safely handles + * incomplete objects. Since input visitors never produce an + * incomplete object, such an object is possible only by manual + * construction. * * For the QAPI object types (structs, unions, and alternates), there * is an additional generated function in qapi-visit-MODULE.h @@ -100,23 +110,20 @@ * * void qapi_free_FOO(FOO *obj); * - * where behaves like free() in that @obj may be NULL. Such objects - * may also be used with the following macro, provided alongside the - * clone visitor: + * Does nothing when @obj is NULL. + * + * Such objects may also be used with macro * * Type *QAPI_CLONE(Type, src); * - * in order to perform a deep clone of @src. Because of the generated - * qapi_free functions and the QAPI_CLONE() macro, the clone and - * dealloc visitor should not be used directly outside of QAPI code. + * in order to perform a deep clone of @src. * - * QAPI types can also inherit from a base class; when this happens, a - * function is generated for easily going from the derived type to the - * base type: + * For QAPI types can that inherit from a base type, a function is + * generated for going from the derived type to the base type: * * BASE *qapi_CHILD_base(CHILD *obj); * - * For a real QAPI struct, typical input usage involves: + * Typical input visitor usage involves: * * * Foo *f; @@ -153,7 +160,7 @@ * qapi_free_FooList(l); * * - * Similarly, typical output usage is: + * Typical output visitor usage: * * * Foo *f =3D ...obtain populated object... @@ -172,17 +179,8 @@ * visit_free(v); * * - * When visiting a real QAPI struct, this file provides several - * helpers that rely on in-tree information to control the walk: - * visit_optional() for the 'has_member' field associated with - * optional 'member' in the C struct; and visit_next_list() for - * advancing through a FooList linked list. Similarly, the - * visit_is_input() helper makes it possible to write code that is - * visitor-agnostic everywhere except for cleanup. Only the generated - * visit_type functions need to use these helpers. - * * It is also possible to use the visitors to do a virtual walk, where - * no actual QAPI struct is present. In this situation, decisions + * no actual QAPI object is present. In this situation, decisions * about what needs to be walked are made by the calling code, and * structured visits are split between pairs of start and end methods * (where the end method must be called if the start function @@ -227,6 +225,12 @@ * out: * visit_free(v); * + * + * This file provides helpers for use by the generated + * visit_type_FOO(): visit_optional() for the 'has_member' field + * associated with optional 'member' in the C struct, + * visit_next_list() for advancing through a FooList linked list, and + * visit_is_input() for cleaning up on failure. */ =20 /*** Useful types ***/ --=20 2.21.1 From nobody Mon Feb 9 01:00:11 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587658000; cv=none; d=zohomail.com; s=zohoarc; b=lrQJACNwTB4tPZCgFNhCxj72Y7SQuzDLN+IdPEfXnxXR3kiSB8XdnwLjgOimB6QCCPwrdspp0S3CBxk6SQgvUZ0w8P2Y7haoX9o+19mIMoOaBiyKXFiCY8iE4AzCD9QN/hquLRY6ADIj98CPX4Gu2KQtnL9gUGWifGuGlg+LYJ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587658000; 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=q+38xZMcsmrlkiHJa+s7iGaz9zjdOxAOUCjVLXhzS9k=; b=evZ83/XZ0sY3j7PiMT8QkQoYX/XMXiaUfzaMmbr8F+N14OhePjZoxPIZS9aDvJZ9p3NWFgGPH+ulkbAgUu6eA4xi/HWjhzB1DNdceZ+0dyJZdCqdspCzM6YTwzwwJQqmObM9UXLAs5INLXt7cVc5LxMdtj80h2NWe6FZZJnmXIw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587658000498938.7889631785324; Thu, 23 Apr 2020 09:06:40 -0700 (PDT) Received: from localhost ([::1]:57948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReN3-0005WI-Mk for importer@patchew.org; Thu, 23 Apr 2020 12:06:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59914) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReHn-000650-Hh for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jReHT-000269-IP for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:11 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:58838 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jReHS-000204-1z for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:00:50 -0400 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-472-x1k_HhMjMV6G8YhMD5rScA-1; Thu, 23 Apr 2020 12:00:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B070E106B245; Thu, 23 Apr 2020 16:00:39 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7964A60635; Thu, 23 Apr 2020 16:00:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6711811358C2; Thu, 23 Apr 2020 18:00:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587657642; h=from:from: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; bh=q+38xZMcsmrlkiHJa+s7iGaz9zjdOxAOUCjVLXhzS9k=; b=SjulT+HTvZn/WqJHXuFnPWO7WCz9WNjZGqGWMwCK68OnYtlg6GHa0WlV956tDLw2GEYtiE p/j74QqsjUS2lJvfM2ZabZzHOWWCCUo6tupfkPCgQjZugU00aCkDcinxBiZ6aIg85xVjEL Ju9UZvUWOugB/EdPuz1ofO19A0NTdPY= X-MC-Unique: x1k_HhMjMV6G8YhMD5rScA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 06/13] qapi: Assert incomplete object occurs only in dealloc visitor Date: Thu, 23 Apr 2020 18:00:29 +0200 Message-Id: <20200423160036.7048-7-armbru@redhat.com> In-Reply-To: <20200423160036.7048-1-armbru@redhat.com> References: <20200423160036.7048-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/23 03:23:21 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- include/qapi/visitor.h | 5 +++++ qapi/qapi-visit-core.c | 5 +++++ scripts/qapi/visit.py | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index a425ea514c..2d40d2fe0f 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -479,6 +479,11 @@ void visit_type_enum(Visitor *v, const char *name, int= *obj, */ bool visit_is_input(Visitor *v); =20 +/* + * Check if visitor is a dealloc visitor. + */ +bool visit_is_dealloc(Visitor *v); + /*** Visiting built-in types ***/ =20 /* diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index 5365561b07..d4aac206cf 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -142,6 +142,11 @@ bool visit_is_input(Visitor *v) return v->type =3D=3D VISITOR_INPUT; } =20 +bool visit_is_dealloc(Visitor *v) +{ + return v->type =3D=3D VISITOR_DEALLOC; +} + void visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **er= rp) { assert(obj); diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 23d9194aa4..e3467b770b 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -189,6 +189,8 @@ void visit_type_%(c_name)s(Visitor *v, const char *name= , %(c_name)s **obj, Error goto out; } if (!*obj) { + /* incomplete */ + assert(visit_is_dealloc(v)); goto out_obj; } switch ((*obj)->type) { @@ -260,6 +262,8 @@ void visit_type_%(c_name)s(Visitor *v, const char *name= , %(c_name)s **obj, Error goto out; } if (!*obj) { + /* incomplete */ + assert(visit_is_dealloc(v)); goto out_obj; } visit_type_%(c_name)s_members(v, *obj, &err); --=20 2.21.1 From nobody Mon Feb 9 01:00:11 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587658440; cv=none; d=zohomail.com; s=zohoarc; b=TDNE2sNQu0wgKeuDcMzpJDxPlCzxF5YwhcBqf9ZQwhyVh9cnEKAr0MBX2Plsv2CUS0/Vzog34g8hTF9FusilXfAy2aymBhHPyOoy61ZF1PvcjUG+82OWwRQM9buw3rAOpZ2FVg2LiFheUZVGpqfN2WGeJjnG0fTB/D0Tj4ezDyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587658440; 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=Y2jcaWXJL7+Y8beWBsofv6D3+PvqGhK2beksT/pD30Q=; b=F3kCVRR5x1657E5jklbVQBC/4ioHV0Pwvkd74ahGS1yPxRYkpnSs738FuU3ZVHXRD9PRtKyrechMOBaVN73vU7Ip8Y6WpkpZBBIATRx5/C9jUjCXnKlVDtJiBsLOZcWZCzBtAPOFALAQBXuNTtoCPdx4VnO+c024gVLsiQA37ZM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587658440052566.745616243151; Thu, 23 Apr 2020 09:14:00 -0700 (PDT) Received: from localhost ([::1]:58626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReU9-0002Jo-Kq for importer@patchew.org; Thu, 23 Apr 2020 12:13:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59972) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReHr-0006BC-2T for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jReHa-0002DM-F8 for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:14 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:22382 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jReHX-00020F-HU for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:00:58 -0400 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-322-J0vzZe5vNeyjP-hJzz-kxQ-1; Thu, 23 Apr 2020 12:00:41 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EEB45835B45; Thu, 23 Apr 2020 16:00:39 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7849560609; Thu, 23 Apr 2020 16:00:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6A31A11358C3; Thu, 23 Apr 2020 18:00:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587657642; h=from:from: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; bh=Y2jcaWXJL7+Y8beWBsofv6D3+PvqGhK2beksT/pD30Q=; b=Ba8cdSevhYm+n9Iy9wUXWxaKPLB0c3irinF8DVe6CUpreV7wX6pI2ydPb6eJEN1pj4JmSo kxXlVMu32f+fIcnb050obtYbZSd5u9V5j4xNI8rlL06emA+lKd0fEgyJlvAEZMKAvKKgc0 BAofMwfGXfOaSDepX9JRNyWkTVg3tIk= X-MC-Unique: J0vzZe5vNeyjP-hJzz-kxQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 07/13] qapi: Fix Visitor contract for start_alternate() Date: Thu, 23 Apr 2020 18:00:30 +0200 Message-Id: <20200423160036.7048-8-armbru@redhat.com> In-Reply-To: <20200423160036.7048-1-armbru@redhat.com> References: <20200423160036.7048-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=armbru@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/23 05:42:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The contract demands v->start_alternate() for input and dealloc visitors, but visit_start_alternate() actually requires it for input and clone visitors. Fix the contract, and delete superfluous qapi_dealloc_start_alternate(). Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- include/qapi/visitor-impl.h | 5 ++--- qapi/qapi-dealloc-visitor.c | 7 ------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h index 8ccb3b6c20..252206dc0d 100644 --- a/include/qapi/visitor-impl.h +++ b/include/qapi/visitor-impl.h @@ -67,13 +67,12 @@ struct Visitor /* Must be set */ void (*end_list)(Visitor *v, void **list); =20 - /* Must be set by input and dealloc visitors to visit alternates; - * optional for output visitors. */ + /* Must be set by input and clone visitors to visit alternates */ void (*start_alternate)(Visitor *v, const char *name, GenericAlternate **obj, size_t size, Error **errp); =20 - /* Optional, needed for dealloc visitor */ + /* Optional */ void (*end_alternate)(Visitor *v, void **obj); =20 /* Must be set */ diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c index d192724b13..2239fc6417 100644 --- a/qapi/qapi-dealloc-visitor.c +++ b/qapi/qapi-dealloc-visitor.c @@ -34,12 +34,6 @@ static void qapi_dealloc_end_struct(Visitor *v, void **o= bj) } } =20 -static void qapi_dealloc_start_alternate(Visitor *v, const char *name, - GenericAlternate **obj, size_t si= ze, - Error **errp) -{ -} - static void qapi_dealloc_end_alternate(Visitor *v, void **obj) { if (obj) { @@ -123,7 +117,6 @@ Visitor *qapi_dealloc_visitor_new(void) v->visitor.type =3D VISITOR_DEALLOC; v->visitor.start_struct =3D qapi_dealloc_start_struct; v->visitor.end_struct =3D qapi_dealloc_end_struct; - v->visitor.start_alternate =3D qapi_dealloc_start_alternate; v->visitor.end_alternate =3D qapi_dealloc_end_alternate; v->visitor.start_list =3D qapi_dealloc_start_list; v->visitor.next_list =3D qapi_dealloc_next_list; --=20 2.21.1 From nobody Mon Feb 9 01:00:11 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587657947; cv=none; d=zohomail.com; s=zohoarc; b=Wc5nJ/J7Wk6Y95yKkOcafK0j8b4UsOCo/OJAvMLnJ+txpO2Syi/WYoR+spfaf594VHvzOM0FjDakfj3H/kOhIlk2UhYdOCHoM7HtqVfSIw3BR3KJj5vbziFezbV72LVVv+lKAAUi4V7qgiexvd8sk2FHdNJeXwM/lS5nkkKax3s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587657947; 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=Ki/Vk1bXRdCRln7lVdZS5kclwyQexohgQW9c6gBrEMc=; b=ENoF3GlGs1dcsP1SbyS9FWn2UgkU5hztwgp3jpA+RDYzwdhNktqfXqvHQki56YnlDc/05vr+x5wOADGfcuMb7k52QkSGAqPy+xFj+1RLyFc6e5VEsVZG3fxUP5g9Ej4TPIFjJrR/sxw8mz0EEE4TQlekZc0BqDX9gmJiZbSG+WA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158765794790973.30696528021963; Thu, 23 Apr 2020 09:05:47 -0700 (PDT) Received: from localhost ([::1]:57796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReMD-0003Kc-6f for importer@patchew.org; Thu, 23 Apr 2020 12:05:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59924) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReHn-00065f-Vl for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jReHS-00024x-DW for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:11 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:26953 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jReHQ-00020Q-72 for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:00:48 -0400 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-443-BZjfM--bNJeUeGAh0cMPAg-1; Thu, 23 Apr 2020 12:00:41 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4C0AC835B40; Thu, 23 Apr 2020 16:00:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 78E2A5D9DC; Thu, 23 Apr 2020 16:00:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6D83211358C4; Thu, 23 Apr 2020 18:00:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587657642; h=from:from: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; bh=Ki/Vk1bXRdCRln7lVdZS5kclwyQexohgQW9c6gBrEMc=; b=UAD1TuCBd4yaAYgipt2hRSMxBB49lotgq5lbYzIL8p5+jUcBJe4ujSx1YSWRMjtDOWThXX Ez1Izj2ByhachIfnnbeq/dbSfLRlLEtgtumt7zBAB0XJBDEvWQUh/p72f66IhpYU4vQTvX P5OxvB0c0Vzf3fmVZ20Qgyr8hBdGkZs= X-MC-Unique: BZjfM--bNJeUeGAh0cMPAg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 08/13] qapi: Assert output visitors see only valid enum values Date: Thu, 23 Apr 2020 18:00:31 +0200 Message-Id: <20200423160036.7048-9-armbru@redhat.com> In-Reply-To: <20200423160036.7048-1-armbru@redhat.com> References: <20200423160036.7048-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/23 02:14:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" output_type_enum() fails when *obj is not a valid value of the enum type. Should not happen. Drop the check, along with its unit tests. qapi_enum_lookup()'s assertion still guards. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- qapi/qapi-visit-core.c | 9 ------- tests/test-qobject-output-visitor.c | 39 ----------------------------- tests/test-string-output-visitor.c | 19 -------------- 3 files changed, 67 deletions(-) diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index d4aac206cf..80ca83bcb9 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -341,15 +341,6 @@ static void output_type_enum(Visitor *v, const char *n= ame, int *obj, int value =3D *obj; char *enum_str; =20 - /* - * TODO why is this an error, not an assertion? If assertion: - * delete, and rely on qapi_enum_lookup() - */ - if (value < 0 || value >=3D lookup->size) { - error_setg(errp, QERR_INVALID_PARAMETER, name ? name : "null"); - return; - } - enum_str =3D (char *)qapi_enum_lookup(lookup, value); visit_type_str(v, name, &enum_str, errp); } diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-outpu= t-visitor.c index d7761ebf84..1c856d9bd2 100644 --- a/tests/test-qobject-output-visitor.c +++ b/tests/test-qobject-output-visitor.c @@ -141,21 +141,6 @@ static void test_visitor_out_enum(TestOutputVisitorDat= a *data, } } =20 -static void test_visitor_out_enum_errors(TestOutputVisitorData *data, - const void *unused) -{ - EnumOne i, bad_values[] =3D { ENUM_ONE__MAX, -1 }; - - for (i =3D 0; i < ARRAY_SIZE(bad_values) ; i++) { - Error *err =3D NULL; - - visit_type_EnumOne(data->ov, "unused", &bad_values[i], &err); - error_free_or_abort(&err); - visitor_reset(data); - } -} - - static void test_visitor_out_struct(TestOutputVisitorData *data, const void *unused) { @@ -234,26 +219,6 @@ static void test_visitor_out_struct_nested(TestOutputV= isitorData *data, qapi_free_UserDefTwo(ud2); } =20 -static void test_visitor_out_struct_errors(TestOutputVisitorData *data, - const void *unused) -{ - EnumOne bad_values[] =3D { ENUM_ONE__MAX, -1 }; - UserDefOne u =3D {0}; - UserDefOne *pu =3D &u; - int i; - - for (i =3D 0; i < ARRAY_SIZE(bad_values) ; i++) { - Error *err =3D NULL; - - u.has_enum1 =3D true; - u.enum1 =3D bad_values[i]; - visit_type_UserDefOne(data->ov, "unused", &pu, &err); - error_free_or_abort(&err); - visitor_reset(data); - } -} - - static void test_visitor_out_list(TestOutputVisitorData *data, const void *unused) { @@ -821,14 +786,10 @@ int main(int argc, char **argv) &out_visitor_data, test_visitor_out_no_string); output_visitor_test_add("/visitor/output/enum", &out_visitor_data, test_visitor_out_enum); - output_visitor_test_add("/visitor/output/enum-errors", - &out_visitor_data, test_visitor_out_enum_error= s); output_visitor_test_add("/visitor/output/struct", &out_visitor_data, test_visitor_out_struct); output_visitor_test_add("/visitor/output/struct-nested", &out_visitor_data, test_visitor_out_struct_nes= ted); - output_visitor_test_add("/visitor/output/struct-errors", - &out_visitor_data, test_visitor_out_struct_err= ors); output_visitor_test_add("/visitor/output/list", &out_visitor_data, test_visitor_out_list); output_visitor_test_add("/visitor/output/any", diff --git a/tests/test-string-output-visitor.c b/tests/test-string-output-= visitor.c index 1be1540767..3bd732222c 100644 --- a/tests/test-string-output-visitor.c +++ b/tests/test-string-output-visitor.c @@ -203,19 +203,6 @@ static void test_visitor_out_enum(TestOutputVisitorDat= a *data, } } =20 -static void test_visitor_out_enum_errors(TestOutputVisitorData *data, - const void *unused) -{ - EnumOne i, bad_values[] =3D { ENUM_ONE__MAX, -1 }; - - for (i =3D 0; i < ARRAY_SIZE(bad_values) ; i++) { - Error *err =3D NULL; - - visit_type_EnumOne(data->ov, "unused", &bad_values[i], &err); - error_free_or_abort(&err); - } -} - static void output_visitor_test_add(const char *testpath, TestOutputVisitorData *data, @@ -260,12 +247,6 @@ int main(int argc, char **argv) &out_visitor_data, test_visitor_out_enum, fals= e); output_visitor_test_add("/string-visitor/output/enum-human", &out_visitor_data, test_visitor_out_enum, true= ); - output_visitor_test_add("/string-visitor/output/enum-errors", - &out_visitor_data, test_visitor_out_enum_error= s, - false); - output_visitor_test_add("/string-visitor/output/enum-errors-human", - &out_visitor_data, test_visitor_out_enum_error= s, - true); output_visitor_test_add("/string-visitor/output/intList", &out_visitor_data, test_visitor_out_intList, f= alse); output_visitor_test_add("/string-visitor/output/intList-human", --=20 2.21.1 From nobody Mon Feb 9 01:00:11 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587658174; cv=none; d=zohomail.com; s=zohoarc; b=a7WvCv0nakqQp1Gsmy7oKlPvKqf3FmuZy5XM5kvYfpkfAQ/LR4PT2pfvHcAPPE41hEXstDjTP1Ypc/r8FMdC/zCrR+xOSDcVxnRsPxKzlK7lH19guzq02S63f1ODB8jODvFnyPs/h8qGqz56u07qjseGxrskXDuiDhL8qyxHngU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587658174; 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=2K7axtxXgjXDGGMpxgeovyJuxWoALcdT61SDt3E7mDA=; b=GLtL9vbi4U8xXF3Wya9vA5jYwTi4QlvH2CfYPW9Gk7NLsYe2l0BqMtCu+b31+zb52ZtPTkG5Qu3GXjl91VqtpM0Y+8Wn8RukBskJhzrdbUie7iN+Noy8JrfC4PVRJ7F2AZZpMAgJlcVQ1QzoXKZBjh8jWIzZTQoShYS5EmRNwwI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587658174965788.0754741942715; Thu, 23 Apr 2020 09:09:34 -0700 (PDT) Received: from localhost ([::1]:58198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRePt-0003Dv-HA for importer@patchew.org; Thu, 23 Apr 2020 12:09:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59946) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReHp-000689-G2 for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jReHa-0002DS-GC for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:13 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:51532 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jReHa-00026V-1t for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:00:58 -0400 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-325-yjo7zZbmMR2IrdimW1V_tA-1; Thu, 23 Apr 2020 12:00:42 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4509A180F123; Thu, 23 Apr 2020 16:00:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 804615D76A; Thu, 23 Apr 2020 16:00:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 70A8411358C5; Thu, 23 Apr 2020 18:00:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587657651; h=from:from: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; bh=2K7axtxXgjXDGGMpxgeovyJuxWoALcdT61SDt3E7mDA=; b=GiiVdRqwr+RB/dY+SW7e6NNr/n3eUjyzMFisU8jIs2M6kWuXSUFu3k4CvBgB+YWGCaBxpn jGm+Rix/KVVN/iepQhTwIq4FLESs9vJre8H3q8fcDGtgeurEmo86ht+r+bHWzOdhf6hK6i nh2/Ul0keDSFAPVfybAxbWa1MBDgrm0= X-MC-Unique: yjo7zZbmMR2IrdimW1V_tA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 09/13] qapi: Assert non-input visitors see only valid narrow integers Date: Thu, 23 Apr 2020 18:00:32 +0200 Message-Id: <20200423160036.7048-10-armbru@redhat.com> In-Reply-To: <20200423160036.7048-1-armbru@redhat.com> References: <20200423160036.7048-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=armbru@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/23 06:43:51 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" visit_type_intN() and visit_type_uintN() fail when the value is out of bounds. This is appropriate with an input visitor: the value comes from input, and input may be bad. It should never happen with the other visitors: the value comes from the caller, and callers must keep it within bounds. Assert that. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- qapi/qapi-visit-core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index 80ca83bcb9..74aa9c04bd 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -160,10 +160,13 @@ static void visit_type_uintN(Visitor *v, uint64_t *ob= j, const char *name, Error *err =3D NULL; uint64_t value =3D *obj; =20 + assert(v->type =3D=3D VISITOR_INPUT || value <=3D max); + v->type_uint64(v, name, &value, &err); if (err) { error_propagate(errp, err); } else if (value > max) { + assert(v->type =3D=3D VISITOR_INPUT); error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null", type); } else { @@ -219,10 +222,13 @@ static void visit_type_intN(Visitor *v, int64_t *obj,= const char *name, Error *err =3D NULL; int64_t value =3D *obj; =20 + assert(v->type =3D=3D VISITOR_INPUT || (value >=3D min && value <=3D m= ax)); + v->type_int64(v, name, &value, &err); if (err) { error_propagate(errp, err); } else if (value < min || value > max) { + assert(v->type =3D=3D VISITOR_INPUT); error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null", type); } else { --=20 2.21.1 From nobody Mon Feb 9 01:00:11 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587657811; cv=none; d=zohomail.com; s=zohoarc; b=StgUllLcljT2XxX1F3XfMG9we4Bwu2T56JS18NvP/DgHQQzOTgxAUJsyHYa1USLbvo3c9itN6ZLU70HZUVfLS7+DDUwC3UacPTgRFP0KEmewYbwJrfbv9yfSPNyerqEcBCSGmRMwjYABRh8w4HwPLxlRal6zYIx8aLj2zFNu0Ac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587657811; 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=xjFKudehGzq1k8YeO6haKGxkdO6BS87KYCXFNVbD73E=; b=gDybn5XJWBAm3OI/bDSrzxP9mFpq04Uz+CvinPsmW1aARO7b6I53CbSEBYP05bRoRLeA3m0ylhce7bSiFIij+dr6DIhufcXFM/JZRlu8ofS1d2Ab0ryOhy3ZMZZlJCMVbfOZ7f1mqNpYbcuAzqs4FoO6FPOpa6Hv30+51itDRjc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587657811062123.80891070981443; Thu, 23 Apr 2020 09:03:31 -0700 (PDT) Received: from localhost ([::1]:57684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReJy-00007L-W7 for importer@patchew.org; Thu, 23 Apr 2020 12:03:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59942) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReHp-00067z-7Q for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jReHS-000254-EN for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:12 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:50671 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jReHQ-00020G-BR for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:00:50 -0400 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-441-6dhV56N8MReEBy6bDdWcgg-1; Thu, 23 Apr 2020 12:00:41 -0400 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 031F9106B258; Thu, 23 Apr 2020 16:00:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7F63C1001920; Thu, 23 Apr 2020 16:00:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 73B8D11358C6; Thu, 23 Apr 2020 18:00:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587657642; h=from:from: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; bh=xjFKudehGzq1k8YeO6haKGxkdO6BS87KYCXFNVbD73E=; b=eiEDeWVCJ6q5ZOyQDsHVoRN5Nj7KqL0c+B9k6WZ71V4Ubefw5lVj0UdFI7WoboFXf2e1W7 ko/jxr5h9DYRc5JHIO1YOnFU/JkC+kl7qFuGppWflEE5xdyi0Il44AeFvdY2/iMbrjUv7G DIS4+CdgY7bVipJX1weUCc3Fa0UauJ0= X-MC-Unique: 6dhV56N8MReEBy6bDdWcgg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 10/13] qapi: Clean up visitor's recovery from input with invalid type Date: Thu, 23 Apr 2020 18:00:33 +0200 Message-Id: <20200423160036.7048-11-armbru@redhat.com> In-Reply-To: <20200423160036.7048-1-armbru@redhat.com> References: <20200423160036.7048-1-armbru@redhat.com> MIME-Version: 1.0 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 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=armbru@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/23 06:43:51 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" An alternate type's visit_type_FOO() fails when it runs into an invalid ->type. If it's an input visit, we then need to free the the object we got from visit_start_alternate(). We do that with qapi_free_FOO(), which uses the dealloc visitor. Trouble is that object is in a bad state: its ->type is invalid. So the dealloc visitor will run into the same error again, and the error recovery skips deallocating the alternate's (invalid) alternative. This is a roundabout way to g_free() the alternate. Simplify: replace the qapi_free_FOO() by g_free(). Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- scripts/qapi/visit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index e3467b770b..3b28ba93f3 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -238,7 +238,7 @@ void visit_type_%(c_name)s(Visitor *v, const char *name= , %(c_name)s **obj, Error out_obj: visit_end_alternate(v, (void **)obj); if (err && visit_is_input(v)) { - qapi_free_%(c_name)s(*obj); + g_free(*obj); *obj =3D NULL; } out: --=20 2.21.1 From nobody Mon Feb 9 01:00:11 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587657961; cv=none; d=zohomail.com; s=zohoarc; b=Dqeeu/r5Qj/ZuM8DrnwcYWRc009dZ3p/pB5toJBQa1aB0uggjKESlZxYnTxOh1JoNUfEIeUvTjO7ZPz0I+PqTc8yqvrGxoYMoNRNT5oU0ZbMl59sZ2uKbh9Sit/x/Hr9+77tS/MDJUtFsnUb6RxvnFQubzAPEQT5l0dnco+O+3I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587657961; 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=pb2YwYl+OshYLE4cqDBEMddewQ6UTsV7BX3WUShSshU=; b=bl8Z+UhxqNTK3RL2v2Bih2B+YqILFOSNNSWIBbQ6msaJ6dNd3RLFB5LenQByxKi5EZig6W6TYBcP1BfMAtj6J7gJktnD5ONOlnElvBcSEY54Rc/ODf45V7qcYhEY/K1PKw3Jmu6Yxpo419/Nv8cKqlXs7DfEvAeVXWEeFpd9xVc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587657961384309.0849635236515; Thu, 23 Apr 2020 09:06:01 -0700 (PDT) Received: from localhost ([::1]:57888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReMQ-00040h-8D for importer@patchew.org; Thu, 23 Apr 2020 12:05:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59954) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReHq-00068y-1O for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jReHa-0002D1-DA for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:13 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:25251 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jReHT-00022r-Ch for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:00:55 -0400 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-414-jvONd2-XMIuTYNpz9QwmrA-1; Thu, 23 Apr 2020 12:00:43 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3C91CA0C19; Thu, 23 Apr 2020 16:00:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 853ED6060D; Thu, 23 Apr 2020 16:00:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 76E8E11358C7; Thu, 23 Apr 2020 18:00:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587657648; h=from:from: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; bh=pb2YwYl+OshYLE4cqDBEMddewQ6UTsV7BX3WUShSshU=; b=OFtjlD4Ua194FKCdC+KnDZzIuLw/TRcNhBuSwdU2uPrltPRCH4TjX7x4MHXRs9tGjfxsDU G4kE1o27GF9Y/50uhorLTc4Gnbe9TOs8CMd7ymDE2cC8duUXyp/RRE6kSvhEGeQfbj/9rd 8BbW5tX/gUcw1pE8crNUI2hk4kkNflo= X-MC-Unique: jvONd2-XMIuTYNpz9QwmrA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 11/13] qapi: Assert non-input visitors see only valid alternate tags Date: Thu, 23 Apr 2020 18:00:34 +0200 Message-Id: <20200423160036.7048-12-armbru@redhat.com> In-Reply-To: <20200423160036.7048-1-armbru@redhat.com> References: <20200423160036.7048-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/23 03:23:21 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" An alternate type's visit_type_FOO() fails when it runs into an invalid ->type. This is appropriate with an input visitor: visit_start_alternate() sets ->type according to the input, and bad input can lead to bad ->type. It should never happen with an output, clone or dealloc visitor: if it did, the alternate being output, cloned or deallocated would be messed up beyond repair. Assert that. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- scripts/qapi/visit.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 3b28ba93f3..99b73eb7c1 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -232,6 +232,7 @@ void visit_type_%(c_name)s(Visitor *v, const char *name= , %(c_name)s **obj, Error case QTYPE_NONE: abort(); default: + assert(visit_is_input(v)); error_setg(&err, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", "%(name)s"); } --=20 2.21.1 From nobody Mon Feb 9 01:00:11 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587658078; cv=none; d=zohomail.com; s=zohoarc; b=kgs4FOt3bgGe3xW68tLFimnF/O6kQnMrb9lt8vgmzfYl54wKnp/L+/SD8+Pr2nwIOXIx/5id7E7N/lCtIidUQpkHyEJF7F2MaOU5Jjdv9O05GCE/0mci3xhYyuMb0FpD6dz5r+vxua8toAq2pvaIG1FNZij9ksMUHlYisPmrMWQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587658078; 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=TRwX4dcdWCKyF0YHzid5/UZxgmyB7MTI5Hz9JbacchE=; b=GhqasnvYh03Ihn8RwDUR4T0kffyKhY0iNujfYzMg3bV8YMtaEwNYplRPORzljm9OwS9AEO3sOprOgb+mIXdXiduQIA9B95BFxi7IFW23vbGJ46BRF8MFTm8x5zMzlJnY35CDrRmE/mmuXPZpuzGnF3BXY9ll/ZPTzanHeE8bLDE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15876580788231022.0929509816792; Thu, 23 Apr 2020 09:07:58 -0700 (PDT) Received: from localhost ([::1]:58052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReOL-00088N-2K for importer@patchew.org; Thu, 23 Apr 2020 12:07:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59964) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReHq-00069b-Aa for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jReHT-00026g-S2 for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:14 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:38729 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jReHS-00020t-3u for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:00:51 -0400 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-454-MUofmJqyPSSMZBD7A5tCjg-1; Thu, 23 Apr 2020 12:00:41 -0400 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 225838015CF; Thu, 23 Apr 2020 16:00:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8BEA91001B30; Thu, 23 Apr 2020 16:00:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7A3B911358C8; Thu, 23 Apr 2020 18:00:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587657643; h=from:from: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; bh=TRwX4dcdWCKyF0YHzid5/UZxgmyB7MTI5Hz9JbacchE=; b=QrkVYH9VQlO2DDjUo4p2M184gb1kYa/b2/QU8sXBflzZ8yRUM3VkeZk8J2W350sAFgs5pg qBNsXuuE+bf+C8aU0wgpUxKJGIyerin+5SpTENIJJtMO2HjrUwOv/duCQRAXODwvgrPbJh HXwzC05JftLhGCIi+/pyge5wAelIINs= X-MC-Unique: MUofmJqyPSSMZBD7A5tCjg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 12/13] qapi: Only input visitors can actually fail Date: Thu, 23 Apr 2020 18:00:35 +0200 Message-Id: <20200423160036.7048-13-armbru@redhat.com> In-Reply-To: <20200423160036.7048-1-armbru@redhat.com> References: <20200423160036.7048-1-armbru@redhat.com> MIME-Version: 1.0 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 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/23 03:23:21 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The previous few commits have made this more obvious, and removed the one exception. Time to clarify the documentation, and drop dead error checking. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- include/qapi/visitor-impl.h | 4 ++++ include/qapi/visitor.h | 40 ++++++++++++++++++++++--------------- block.c | 9 +-------- block/sheepdog.c | 9 +-------- blockdev.c | 16 ++------------- hw/core/machine-hmp-cmds.c | 2 +- monitor/hmp-cmds.c | 3 ++- 7 files changed, 35 insertions(+), 48 deletions(-) diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h index 252206dc0d..98dc533d39 100644 --- a/include/qapi/visitor-impl.h +++ b/include/qapi/visitor-impl.h @@ -43,6 +43,10 @@ typedef enum VisitorType { =20 struct Visitor { + /* + * Only input visitors may fail! + */ + /* Must be set to visit structs */ void (*start_struct)(Visitor *v, const char *name, void **obj, size_t size, Error **errp); diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index 2d40d2fe0f..5573906966 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -82,7 +82,7 @@ * Each function also takes the customary @errp argument (see * qapi/error.h for details), for reporting any errors (such as if a * member @name is not present, or is present but not the specified - * type). + * type). Only input visitors can fail. * * If an error is detected during visit_type_FOO() with an input * visitor, then *@obj will be set to NULL for pointer types, and left @@ -164,19 +164,14 @@ * * * Foo *f =3D ...obtain populated object... - * Error *err =3D NULL; * Visitor *v; * Type *result; * * v =3D FOO_visitor_new(..., &result); - * visit_type_Foo(v, NULL, &f, &err); - * if (err) { - * ...handle error... - * } else { - * visit_complete(v, &result); - * ...use result... - * } + * visit_type_Foo(v, NULL, &f, &error_abort); + * visit_complete(v, &result); * visit_free(v); + * ...use result... * * * It is also possible to use the visitors to do a virtual walk, where @@ -289,6 +284,7 @@ void visit_free(Visitor *v); * case @size is ignored. * * On failure, set *@obj to NULL and store an error through @errp. + * Can happen only when @v is an input visitor. * * After visit_start_struct() succeeds, the caller may visit its * members one after the other, passing the member's name and address @@ -305,7 +301,8 @@ void visit_start_struct(Visitor *v, const char *name, v= oid **obj, /* * Prepare for completing an object visit. * - * On failure, store an error through @errp. + * On failure, store an error through @errp. Can happen only when @v + * is an input visitor. * * Should be called prior to visit_end_struct() if all other * intermediate visit steps were successful, to allow the visitor one @@ -342,6 +339,7 @@ void visit_end_struct(Visitor *v, void **obj); * ignored. * * On failure, set *@list to NULL and store an error through @errp. + * Can happen only when @v is an input visitor. * * After visit_start_list() succeeds, the caller may visit its members * one after the other. A real visit (where @list is non-NULL) uses @@ -375,7 +373,8 @@ GenericList *visit_next_list(Visitor *v, GenericList *t= ail, size_t size); /* * Prepare for completing a list visit. * - * On failure, store an error through @errp. + * On failure, store an error through @errp. Can happen only when @v + * is an input visitor. * * Should be called prior to visit_end_list() if all other * intermediate visit steps were successful, to allow the visitor one @@ -411,6 +410,7 @@ void visit_end_list(Visitor *v, void **list); * (*@obj)->type. Other visitors leave @obj unchanged. * * On failure, set *@obj to NULL and store an error through @errp. + * Can happen only when @v is an input visitor. * * If successful, this must be paired with visit_end_alternate() with * the same @obj to clean up, even if visiting the contents of the @@ -465,11 +465,13 @@ bool visit_optional(Visitor *v, const char *name, boo= l *present); * visitors produce text output. The mapping between enumeration * values and strings is done by the visitor core, using @lookup. * - * On failure, store an error through @errp. + * On failure, store an error through @errp. Can happen only when @v + * is an input visitor. * * May call visit_type_str() under the hood, and the enum visit may * fail even if the corresponding string visit succeeded; this implies - * that visit_type_str() must have no unwelcome side effects. + * that an input visitor's visit_type_str() must have no unwelcome + * side effects. */ void visit_type_enum(Visitor *v, const char *name, int *obj, const QEnumLookup *lookup, Error **errp); @@ -495,7 +497,8 @@ bool visit_is_dealloc(Visitor *v); * @obj must be non-NULL. Input visitors set *@obj to the value; * other visitors will leave *@obj unchanged. * - * On failure, store an error through @errp. + * On failure, store an error through @errp. Can happen only when @v + * is an input visitor. */ void visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **er= rp); =20 @@ -573,7 +576,8 @@ void visit_type_size(Visitor *v, const char *name, uint= 64_t *obj, * @obj must be non-NULL. Input visitors set *@obj to the value; * other visitors will leave *@obj unchanged. * - * On failure, store an error through @errp. + * On failure, store an error through @errp. Can happen only when @v + * is an input visitor. */ void visit_type_bool(Visitor *v, const char *name, bool *obj, Error **errp= ); =20 @@ -592,6 +596,7 @@ void visit_type_bool(Visitor *v, const char *name, bool= *obj, Error **errp); * into @obj for use by an output visitor. * * On failure, set *@obj to NULL and store an error through @errp. + * Can happen only when @v is an input visitor. * * FIXME: Callers that try to output NULL *obj should not be allowed. */ @@ -607,7 +612,8 @@ void visit_type_str(Visitor *v, const char *name, char = **obj, Error **errp); * other visitors will leave *@obj unchanged. Visitors should * document if infinity or NaN are not permitted. * - * On failure, store an error through @errp. + * On failure, store an error through @errp. Can happen only when @v + * is an input visitor. */ void visit_type_number(Visitor *v, const char *name, double *obj, Error **errp); @@ -623,6 +629,7 @@ void visit_type_number(Visitor *v, const char *name, do= uble *obj, * for output visitors. * * On failure, set *@obj to NULL and store an error through @errp. + * Can happen only when @v is an input visitor. * * Note that some kinds of input can't express arbitrary QObject. * E.g. the visitor returned by qobject_input_visitor_new_keyval() @@ -640,6 +647,7 @@ void visit_type_any(Visitor *v, const char *name, QObje= ct **obj, Error **errp); * other visitors ignore *@obj. * * On failure, set *@obj to NULL and store an error through @errp. + * Can happen only when @v is an input visitor. */ void visit_type_null(Visitor *v, const char *name, QNull **obj, Error **errp); diff --git a/block.c b/block.c index 2e3905c99e..c11385ae05 100644 --- a/block.c +++ b/block.c @@ -2982,7 +2982,6 @@ BdrvChild *bdrv_open_child(const char *filename, BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp) { BlockDriverState *bs =3D NULL; - Error *local_err =3D NULL; QObject *obj =3D NULL; QDict *qdict =3D NULL; const char *reference =3D NULL; @@ -2995,11 +2994,7 @@ BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef= *ref, Error **errp) assert(ref->type =3D=3D QTYPE_QDICT); =20 v =3D qobject_output_visitor_new(&obj); - visit_type_BlockdevOptions(v, NULL, &options, &local_err); - if (local_err) { - error_propagate(errp, local_err); - goto fail; - } + visit_type_BlockdevOptions(v, NULL, &options, &error_abort); visit_complete(v, &obj); =20 qdict =3D qobject_to(QDict, obj); @@ -3017,8 +3012,6 @@ BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef = *ref, Error **errp) =20 bs =3D bdrv_open_inherit(NULL, reference, qdict, 0, NULL, NULL, errp); obj =3D NULL; - -fail: qobject_unref(obj); visit_free(v); return bs; diff --git a/block/sheepdog.c b/block/sheepdog.c index 59f7ebb171..5f3aead038 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -1854,19 +1854,12 @@ static int sd_create_prealloc(BlockdevOptionsSheepd= og *location, int64_t size, Visitor *v; QObject *obj =3D NULL; QDict *qdict; - Error *local_err =3D NULL; int ret; =20 v =3D qobject_output_visitor_new(&obj); - visit_type_BlockdevOptionsSheepdog(v, NULL, &location, &local_err); + visit_type_BlockdevOptionsSheepdog(v, NULL, &location, &error_abort); visit_free(v); =20 - if (local_err) { - error_propagate(errp, local_err); - qobject_unref(obj); - return -EINVAL; - } - qdict =3D qobject_to(QDict, obj); qdict_flatten(qdict); =20 diff --git a/blockdev.c b/blockdev.c index 5faddaa705..9da960b1e7 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3725,14 +3725,8 @@ void qmp_blockdev_add(BlockdevOptions *options, Erro= r **errp) QObject *obj; Visitor *v =3D qobject_output_visitor_new(&obj); QDict *qdict; - Error *local_err =3D NULL; - - visit_type_BlockdevOptions(v, NULL, &options, &local_err); - if (local_err) { - error_propagate(errp, local_err); - goto fail; - } =20 + visit_type_BlockdevOptions(v, NULL, &options, &error_abort); visit_complete(v, &obj); qdict =3D qobject_to(QDict, obj); =20 @@ -3760,7 +3754,6 @@ void qmp_x_blockdev_reopen(BlockdevOptions *options, = Error **errp) AioContext *ctx; QObject *obj; Visitor *v =3D qobject_output_visitor_new(&obj); - Error *local_err =3D NULL; BlockReopenQueue *queue; QDict *qdict; =20 @@ -3777,12 +3770,7 @@ void qmp_x_blockdev_reopen(BlockdevOptions *options,= Error **errp) } =20 /* Put all options in a QDict and flatten it */ - visit_type_BlockdevOptions(v, NULL, &options, &local_err); - if (local_err) { - error_propagate(errp, local_err); - goto fail; - } - + visit_type_BlockdevOptions(v, NULL, &options, &error_abort); visit_complete(v, &obj); qdict =3D qobject_to(QDict, obj); =20 diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c index b76f7223af..39999c47c5 100644 --- a/hw/core/machine-hmp-cmds.c +++ b/hw/core/machine-hmp-cmds.c @@ -113,7 +113,7 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict) =20 while (m) { v =3D string_output_visitor_new(false, &str); - visit_type_uint16List(v, NULL, &m->value->host_nodes, NULL); + visit_type_uint16List(v, NULL, &m->value->host_nodes, &error_abort= ); monitor_printf(mon, "memory backend: %s\n", m->value->id); monitor_printf(mon, " size: %" PRId64 "\n", m->value->size); monitor_printf(mon, " merge: %s\n", diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 9b94e67879..7f6e982dc8 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -334,7 +334,8 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) Visitor *v; char *str; v =3D string_output_visitor_new(false, &str); - visit_type_uint32List(v, NULL, &info->postcopy_vcpu_blocktime, NUL= L); + visit_type_uint32List(v, NULL, &info->postcopy_vcpu_blocktime, + &error_abort); visit_complete(v, &str); monitor_printf(mon, "postcopy vcpu blocktime: %s\n", str); g_free(str); --=20 2.21.1 From nobody Mon Feb 9 01:00:11 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587658213; cv=none; d=zohomail.com; s=zohoarc; b=bn2iuN6Is5RHwu+ABxpLMKq2rvLnPlrdOuZMuGe78LCqSaoL9VyEWWG2NuaDrJzo6ZfjUxbP6N/7587nI275BgUtKYNqKgMkxd0KOb+az0HxzBGOTJ/Z3UZ/UobZ9Ju2nsQWl2UisHTlizxILfRMbi1ue/OaQ/BA49XSLwnYZGQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587658213; 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=oJR5MGxlqBA/IoAh5ej5QaLjfHJDLjfiVO5Vcdz5yqk=; b=IaoCvwOTHndGioqHlwUrnhTszQbKpxcUKKg2gv0vhlFREGg7jvRFCMKIpItBSAJegpW3/6Sb9DvWG3YKcLHGP9xVmqlWDhe1VgUK+/OQuG95YjhchpAwnubLbuwWBghQWcQr49C3N6sOf9XmNFkvRFPBlpj2H9SOnXiGNLCeYj0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587658213260275.15199602714017; Thu, 23 Apr 2020 09:10:13 -0700 (PDT) Received: from localhost ([::1]:58272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReQV-0004wJ-Sp for importer@patchew.org; Thu, 23 Apr 2020 12:10:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59936) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jReHo-00067W-TJ for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jReHa-0002DB-Cx for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:01:12 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:55876 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jReHT-00021B-I9 for qemu-devel@nongnu.org; Thu, 23 Apr 2020 12:00:55 -0400 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-238-23z1WIlSOKKEHZc9iHVsEw-1; Thu, 23 Apr 2020 12:00:42 -0400 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 4EC24A0C1F; Thu, 23 Apr 2020 16:00:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 13BEF1002389; Thu, 23 Apr 2020 16:00:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7D61E11358CA; Thu, 23 Apr 2020 18:00:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587657644; h=from:from: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; bh=oJR5MGxlqBA/IoAh5ej5QaLjfHJDLjfiVO5Vcdz5yqk=; b=Xte07jhkmhnyrMtUC9SAAe3EwKJSLpe+KBhaTuPlvlPgwnMs7QwpS+rKfANO4+Yk/3MShK taOHI93Jlvgyt4NZvQaVNLREWnRm2KM2HqshWiWxfXTFYJ9eQ7UzchaAPWCkervRAC5U1Q Lxv6evfEG4w3m6KRx+uHo1a3b1sQxhQ= X-MC-Unique: 23z1WIlSOKKEHZc9iHVsEw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 13/13] qom: Simplify object_property_get_enum() Date: Thu, 23 Apr 2020 18:00:36 +0200 Message-Id: <20200423160036.7048-14-armbru@redhat.com> In-Reply-To: <20200423160036.7048-1-armbru@redhat.com> References: <20200423160036.7048-1-armbru@redhat.com> MIME-Version: 1.0 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 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/23 03:23:21 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- qom/object.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/qom/object.c b/qom/object.c index 1812f79224..be700e831f 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1550,11 +1550,9 @@ int object_property_get_enum(Object *obj, const char= *name, } visit_complete(v, &str); visit_free(v); - v =3D string_input_visitor_new(str); - visit_type_enum(v, name, &ret, enumprop->lookup, errp); =20 + ret =3D qapi_enum_parse(enumprop->lookup, str, -1, errp); g_free(str); - visit_free(v); =20 return ret; } --=20 2.21.1