qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: mdroth@linux.vnet.ibm.com
Subject: [Qemu-devel] [PATCH 1/9] qapi: Drop check_type()'s redundant parameter @allow_optional
Date: Wed, 28 Aug 2019 22:26:33 +0200	[thread overview]
Message-ID: <20190828202641.24752-2-armbru@redhat.com> (raw)
In-Reply-To: <20190828202641.24752-1-armbru@redhat.com>

check_type() uses @allow_optional only when @value is a dictionary and
@allow_dict is True.  All callers that pass allow_dict=True also pass
allow_optional=True.

Therefore, @allow_optional is always True when check_type() uses it.
Drop the redundant parameter.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi/common.py | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index d61bfdc526..9aefcfe015 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -783,9 +783,8 @@ def check_if(expr, info):
         check_if_str(ifcond, info)
 
 
-def check_type(info, source, value, allow_array=False,
-               allow_dict=False, allow_optional=False,
-               allow_metas=[]):
+def check_type(info, source, value,
+               allow_array=False, allow_dict=False, allow_metas=[]):
     global all_names
 
     if value is None:
@@ -821,7 +820,7 @@ def check_type(info, source, value, allow_array=False,
     # value is a dictionary, check that each member is okay
     for (key, arg) in value.items():
         check_name(info, "Member of %s" % source, key,
-                   allow_optional=allow_optional)
+                   allow_optional=True)
         if c_name(key, False) == 'u' or c_name(key, False).startswith('has_'):
             raise QAPISemError(info, "Member of %s uses reserved name '%s'"
                                % (source, key))
@@ -843,14 +842,14 @@ def check_command(expr, info):
     if boxed:
         args_meta += ['union', 'alternate']
     check_type(info, "'data' for command '%s'" % name,
-               expr.get('data'), allow_dict=not boxed, allow_optional=True,
+               expr.get('data'), allow_dict=not boxed,
                allow_metas=args_meta)
     returns_meta = ['union', 'struct']
     if name in returns_whitelist:
         returns_meta += ['built-in', 'alternate', 'enum']
     check_type(info, "'returns' for command '%s'" % name,
                expr.get('returns'), allow_array=True,
-               allow_optional=True, allow_metas=returns_meta)
+               allow_metas=returns_meta)
 
 
 def check_event(expr, info):
@@ -861,7 +860,7 @@ def check_event(expr, info):
     if boxed:
         meta += ['union', 'alternate']
     check_type(info, "'data' for event '%s'" % name,
-               expr.get('data'), allow_dict=not boxed, allow_optional=True,
+               expr.get('data'), allow_dict=not boxed,
                allow_metas=meta)
 
 
@@ -889,7 +888,7 @@ def check_union(expr, info):
     else:
         # The object must have a string or dictionary 'base'.
         check_type(info, "'base' for union '%s'" % name,
-                   base, allow_dict=True, allow_optional=True,
+                   base, allow_dict=True,
                    allow_metas=['struct'])
         if not base:
             raise QAPISemError(info, "Flat union '%s' must have a base"
@@ -1012,7 +1011,7 @@ def check_struct(expr, info):
     features = expr.get('features')
 
     check_type(info, "'data' for struct '%s'" % name, members,
-               allow_dict=True, allow_optional=True)
+               allow_dict=True)
     check_type(info, "'base' for struct '%s'" % name, expr.get('base'),
                allow_metas=['struct'])
 
-- 
2.21.0



  reply	other threads:[~2019-08-28 20:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-28 20:26 [Qemu-devel] [PATCH 0/9] qapi: Schema language cleanups & doc improvements Markus Armbruster
2019-08-28 20:26 ` Markus Armbruster [this message]
2019-08-28 20:26 ` [Qemu-devel] [PATCH 2/9] qapi: Drop support for boxed alternate for commands, events Markus Armbruster
2019-08-30 12:44   ` Markus Armbruster
2019-08-28 20:26 ` [Qemu-devel] [PATCH 3/9] docs/devel/qapi-code-gen: Minor specification fixes Markus Armbruster
2019-08-28 20:26 ` [Qemu-devel] [PATCH 4/9] qapi: Outlaw control characters in strings Markus Armbruster
2019-08-28 20:26 ` [Qemu-devel] [PATCH 5/9] tests/qapi-schema: Consistently name string tests string-FOO Markus Armbruster
2019-08-28 20:26 ` [Qemu-devel] [PATCH 6/9] docs/devel/qapi-code-gen: Reorder sections for readability Markus Armbruster
2019-08-28 20:26 ` [Qemu-devel] [PATCH 7/9] docs/devel/qapi-code-gen: Rewrite compatibility considerations Markus Armbruster
2019-08-28 20:26 ` [Qemu-devel] [PATCH 8/9] docs/devel/qapi-code-gen: Rewrite introduction to schema Markus Armbruster
2019-08-28 20:26 ` [Qemu-devel] [PATCH 9/9] docs/devel/qapi-code-gen: Improve QAPI schema language doc Markus Armbruster
2019-08-28 21:42 ` [Qemu-devel] [PATCH 0/9] qapi: Schema language cleanups & doc improvements no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190828202641.24752-2-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).