summary refs log tree commit diff stats
path: root/scripts/qapi/expr.py
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2021-09-13 11:00:30 +0100
committerPeter Maydell <peter.maydell@linaro.org>2021-09-13 11:00:30 +0100
commiteae587e8e3694b1aceab23239493fb4c7e1a80f5 (patch)
tree7214c3b0c00ebeca6d3338692216057f132fd5a9 /scripts/qapi/expr.py
parent99c44988d5ba1866a411450c877ed818b1b70081 (diff)
parent62f27589f8549d6cf1f7fe21ed55ce6f2f705450 (diff)
downloadfocaccia-qemu-eae587e8e3694b1aceab23239493fb4c7e1a80f5.tar.gz
focaccia-qemu-eae587e8e3694b1aceab23239493fb4c7e1a80f5.zip
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-09-13' into staging
QAPI patches patches for 2021-09-13

# gpg: Signature made Mon 13 Sep 2021 08:53:42 BST
# gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg:                issuer "armbru@redhat.com"
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-qapi-2021-09-13:
  qapi: Fix bogus error for 'if': { 'not': '' }
  tests/qapi-schema: Cover 'not' condition with empty argument
  qapi: Bury some unused code in class Indentation
  qapi: Drop Indentation.__bool__()
  qapi: Fix a botched type annotation

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts/qapi/expr.py')
-rw-r--r--scripts/qapi/expr.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py
index b62f0a3640..90bde501b0 100644
--- a/scripts/qapi/expr.py
+++ b/scripts/qapi/expr.py
@@ -293,17 +293,22 @@ def check_if(expr: _JSONObject, info: QAPISourceInfo, source: str) -> None:
                 info,
                 "'if' condition of %s has conflicting keys" % source)
 
-        oper, operands = next(iter(cond.items()))
+        if 'not' in cond:
+            _check_if(cond['not'])
+        elif 'all' in cond:
+            _check_infix('all', cond['all'])
+        else:
+            _check_infix('any', cond['any'])
+
+    def _check_infix(operator: str, operands: object) -> None:
+        if not isinstance(operands, list):
+            raise QAPISemError(
+                info,
+                "'%s' condition of %s must be an array"
+                % (operator, source))
         if not operands:
             raise QAPISemError(
                 info, "'if' condition [] of %s is useless" % source)
-
-        if oper == "not":
-            _check_if(operands)
-            return
-        if oper in ("all", "any") and not isinstance(operands, list):
-            raise QAPISemError(
-                info, "'%s' condition of %s must be an array" % (oper, source))
         for operand in operands:
             _check_if(operand)