[Qemu-devel] [PATCH 17/19] qapi: Fix to .check() empty structs just once

Markus Armbruster posted 19 patches 6 years, 1 month ago
Maintainers: Markus Armbruster <armbru@redhat.com>, Michael Roth <mdroth@linux.vnet.ibm.com>
[Qemu-devel] [PATCH 17/19] qapi: Fix to .check() empty structs just once
Posted by Markus Armbruster 6 years, 1 month ago
QAPISchemaObjectType.check() does nothing for types that have been
checked already.  Except the "has been checked" predicate is broken
for empty types: self.members is [] then, which isn't true.  The bug
is harmless, but fix it anyway: use self.member is not None instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi/common.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index 7e79c42b6a..e2c87d1349 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -1406,7 +1406,7 @@ class QAPISchemaObjectType(QAPISchemaType):
         if self.members is False:               # check for cycles
             raise QAPISemError(self.info,
                                "Object %s contains itself" % self.name)
-        if self.members:
+        if self.members is not None:            # already checked
             return
         self.members = False                    # mark as being checked
         seen = OrderedDict()
-- 
2.21.0


Re: [Qemu-devel] [PATCH 17/19] qapi: Fix to .check() empty structs just once
Posted by Eric Blake 6 years, 1 month ago
On 9/14/19 10:35 AM, Markus Armbruster wrote:
> QAPISchemaObjectType.check() does nothing for types that have been
> checked already.  Except the "has been checked" predicate is broken
> for empty types: self.members is [] then, which isn't true.  The bug
> is harmless, but fix it anyway: use self.member is not None instead.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  scripts/qapi/common.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
> index 7e79c42b6a..e2c87d1349 100644
> --- a/scripts/qapi/common.py
> +++ b/scripts/qapi/common.py
> @@ -1406,7 +1406,7 @@ class QAPISchemaObjectType(QAPISchemaType):
>          if self.members is False:               # check for cycles
>              raise QAPISemError(self.info,
>                                 "Object %s contains itself" % self.name)
> -        if self.members:
> +        if self.members is not None:            # already checked
>              return
>          self.members = False                    # mark as being checked
>          seen = OrderedDict()
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org