qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: marcandre.lureau@redhat.com, jsnow@redhat.com, michael.roth@amd.com
Subject: [PATCH 5/5] qapi: Fix bogus error for 'if': { 'not': '' }
Date: Wed,  8 Sep 2021 06:54:28 +0200	[thread overview]
Message-ID: <20210908045428.2689093-6-armbru@redhat.com> (raw)
In-Reply-To: <20210908045428.2689093-1-armbru@redhat.com>

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi/expr.py             | 21 +++++++++++++--------
 tests/qapi-schema/bad-if-not.err |  2 +-
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py
index b62f0a3640..ad3732c7f0 100644
--- a/scripts/qapi/expr.py
+++ b/scripts/qapi/expr.py
@@ -293,17 +293,22 @@ def _check_if(cond: Union[str, object]) -> 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):
+        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)
 
diff --git a/tests/qapi-schema/bad-if-not.err b/tests/qapi-schema/bad-if-not.err
index b3acdd679a..b33f5e16b8 100644
--- a/tests/qapi-schema/bad-if-not.err
+++ b/tests/qapi-schema/bad-if-not.err
@@ -1,2 +1,2 @@
 bad-if-not.json: In struct 'TestIfStruct':
-bad-if-not.json:2: 'if' condition [] of struct is useless
+bad-if-not.json:2: 'if' condition '' of struct is not a valid identifier
-- 
2.31.1



  parent reply	other threads:[~2021-09-08  4:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-08  4:54 [PATCH 0/5] qapi: Another round of minor fixes and cleanups Markus Armbruster
2021-09-08  4:54 ` [PATCH 1/5] qapi: Fix a botched type annotation Markus Armbruster
2021-09-08  4:54 ` [PATCH 2/5] qapi: Drop Indentation.__bool__() Markus Armbruster
2021-09-13 18:29   ` Eric Blake
2021-09-08  4:54 ` [PATCH 3/5] qapi: Bury some unused code in class Indentation Markus Armbruster
2021-09-08  4:54 ` [PATCH 4/5] tests/qapi-schema: Cover 'not' condition with empty argument Markus Armbruster
2021-09-08  4:54 ` Markus Armbruster [this message]
2021-09-08 13:27   ` [PATCH 5/5] qapi: Fix bogus error for 'if': { 'not': '' } Markus Armbruster
2021-09-08  6:48 ` [PATCH 0/5] qapi: Another round of minor fixes and cleanups Marc-André Lureau
2021-09-13  7:57 ` Markus Armbruster

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=20210908045428.2689093-6-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=michael.roth@amd.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).