From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1EDEFCD11C2 for ; Tue, 19 Mar 2024 15:31:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rmbR3-0008Hm-Kt; Tue, 19 Mar 2024 11:31:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rmbQq-0008FS-65 for qemu-devel@nongnu.org; Tue, 19 Mar 2024 11:31:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rmbQl-0002ZI-Q0 for qemu-devel@nongnu.org; Tue, 19 Mar 2024 11:31:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710862267; 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: in-reply-to:in-reply-to:references:references; bh=iGWjjGr997LVBjLLFPRncequwPhUDZF7nClH4loSotw=; b=CfIn1vU0OuWhCe64n8mMcNypS6TG5gr3eqmh2FsDSWzgTL/Fhg6Hxj52Skpv+7vta3XwIZ CeUzE3vwZsxpt2gVzchUwGCNkybnrHZWXAVqT2+1rMae+UGnAIbZM/1JZFt8lDNM/tgl0P 84SO/BY4wH5RYWtI9jAyz4vgZd8RKlg= Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-428-IGITSao4Puy8th5kk6nuLg-1; Tue, 19 Mar 2024 11:31:04 -0400 X-MC-Unique: IGITSao4Puy8th5kk6nuLg-1 Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-29dfa2c256fso3067009a91.3 for ; Tue, 19 Mar 2024 08:31:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710862263; x=1711467063; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iGWjjGr997LVBjLLFPRncequwPhUDZF7nClH4loSotw=; b=FHsa5vj5erOS+jUwq4RkWlNKOlEgc9WmrxbDBXDqv+ZQ7glYaaAlskNr+biCHKukpq UWn0MHlXPFzP1z84WYPbILNQ/JH7kn8ReZD6z/kS6BxJXG4zarFFyVlvhx/sWZ8GOnv6 429otMvzyeR7MouQuOdBmScFf7n9N7gUXUO9MploHBY/dpbiSuEIBV/4t9+7q/pCJ1gW OKdmtvx6jI6aj5H2iZ0MS7lmjEeEbIKAo2AcIjVYKcTkORNsrrta7ycyccq0/rz30OUb hwcBT5DAJgU6L2a6drybpmRnfFaW2Nh+1T8HNBIOBGCquT2P6DOOnbW5Tk0R380veiZj TPPw== X-Gm-Message-State: AOJu0Yzn7eBRmiCgoHj5gV/Qc+Re145nGzp8J4eIwsoM2ASnKOxS881F 5zOXbCe4i3SG6pbcUeRT/YPBKD6uI+yXXdapYBbG52YYl0fe3MLQ5xw9Rycr8HXv4N3c4hhL1qh KbI9DxoRL5hxQb05ozgumUeZtzuQm9qgnFADMy/SMId6q+l0FHRESoXEEtv/F1YRITIiyh1IbQM Twug0hJPh6Li6yZD5AZ58ErepVldc= X-Received: by 2002:a17:90b:fcb:b0:29b:9f1e:ab2d with SMTP id gd11-20020a17090b0fcb00b0029b9f1eab2dmr13846953pjb.36.1710862263216; Tue, 19 Mar 2024 08:31:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSBZg54i4mJwHW9TxEHgp7M4+jG1CeqJgBELlzEDbwABjm/OUBX61bW2/V6KTDwtGt5FwuZiFIYL8Lc3ygJJ4= X-Received: by 2002:a17:90b:fcb:b0:29b:9f1e:ab2d with SMTP id gd11-20020a17090b0fcb00b0029b9f1eab2dmr13846927pjb.36.1710862262875; Tue, 19 Mar 2024 08:31:02 -0700 (PDT) MIME-Version: 1.0 References: <20240315152301.3621858-1-armbru@redhat.com> <20240315152301.3621858-25-armbru@redhat.com> In-Reply-To: <20240315152301.3621858-25-armbru@redhat.com> From: John Snow Date: Tue, 19 Mar 2024 11:30:50 -0400 Message-ID: Subject: Re: [PATCH v5 24/25] qapi: Tighten check whether implicit object type already exists To: Markus Armbruster Cc: qemu-devel , Peter Maydell , Michael Roth Content-Type: multipart/alternative; boundary="000000000000704bc506140529bd" Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.422, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org --000000000000704bc506140529bd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Mar 15, 2024, 11:23=E2=80=AFAM Markus Armbruster wrote: > Entities with names starting with q_obj_ are implicit object types. > Therefore, QAPISchema._make_implicit_object_type()'s .lookup_entity() > can only return a QAPISchemaObjectType. Assert that. > > Signed-off-by: Markus Armbruster > --- > scripts/qapi/schema.py | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py > index e52930a48a..a6180f93c6 100644 > --- a/scripts/qapi/schema.py > +++ b/scripts/qapi/schema.py > @@ -1297,8 +1297,9 @@ def _make_implicit_object_type( > return None > # See also QAPISchemaObjectTypeMember.describe() > name =3D 'q_obj_%s-%s' % (name, role) > - typ =3D self.lookup_entity(name, QAPISchemaObjectType) > + typ =3D self.lookup_entity(name) > if typ: > + assert(isinstance(typ, QAPISchemaObjectType)) > # The implicit object type has multiple users. This can > # only be a duplicate definition, which will be flagged > # later. > -- > 2.44.0 > Seems obviously fine, though I don't suppose this narrowing will be "remembered" by the type system. Do we care? Reviewed-by: John Snow > --000000000000704bc506140529bd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Fri, Mar 15, 2024, 11:23=E2=80=AFAM Markus Armbrust= er <armbru@redhat.com> wrote= :
Entities with names starting with= q_obj_ are implicit object types.
Therefore, QAPISchema._make_implicit_object_type()'s .lookup_entity() can only return a QAPISchemaObjectType.=C2=A0 Assert that.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
=C2=A0scripts/qapi/schema.py | 3 ++-
=C2=A01 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index e52930a48a..a6180f93c6 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -1297,8 +1297,9 @@ def _make_implicit_object_type(
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return None
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# See also QAPISchemaObjectTypeMember.des= cribe()
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0name =3D 'q_obj_%s-%s' % (name, r= ole)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 typ =3D self.lookup_entity(name, QAPISchemaObj= ectType)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 typ =3D self.lookup_entity(name)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if typ:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 assert(isinstance(typ, QAPISchem= aObjectType))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# The implicit object type = has multiple users.=C2=A0 This can
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# only be a duplicate defin= ition, which will be flagged
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# later.
--
2.44.0

Seems obviously fine, though I don't suppose this narrowing will = be "remembered" by the type system. Do we care?

Reviewed-by: John Snow <jsnow@redhat.com>
--000000000000704bc506140529bd--