]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qapi: Reject blank 'if' conditions in addition to empty ones
authorMarkus Armbruster <armbru@redhat.com>
Sat, 14 Sep 2019 15:34:58 +0000 (17:34 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 24 Sep 2019 12:07:23 +0000 (14:07 +0200)
"'if': 'COND'" generates "#if COND".  We reject empty COND because it
won't compile.  Blank COND won't compile any better, so reject that,
too.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-12-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
scripts/qapi/common.py
tests/qapi-schema/bad-if-list.err
tests/qapi-schema/bad-if-list.json

index a58e90497849e86d7bd7929450f8a88a9381f270..2b461648545d831876d5d82f17b4d17600e77494 100644 (file)
@@ -742,8 +742,9 @@ def check_if(expr, info):
         if not isinstance(ifcond, str):
             raise QAPISemError(
                 info, "'if' condition must be a string or a list of strings")
-        if ifcond == '':
-            raise QAPISemError(info, "'if' condition '' makes no sense")
+        if ifcond.strip() == '':
+            raise QAPISemError(info, "'if' condition '%s' makes no sense"
+                               % ifcond)
 
     ifcond = expr.get('if')
     if ifcond is None:
index 0af6316f783b6e182605a121c0b7c2f4d24a95f9..53af0990834b2f6e2a25f9f18f759f8fc93c91a8 100644 (file)
@@ -1 +1 @@
-tests/qapi-schema/bad-if-list.json:2: 'if' condition '' makes no sense
+tests/qapi-schema/bad-if-list.json:2: 'if' condition ' ' makes no sense
index 49ced9b9cac450331b8dbe885da948169ec392c8..ea3d95bb6b5f3ff824e5cb8106136addf0aaed15 100644 (file)
@@ -1,3 +1,3 @@
 # check invalid 'if' content
 { 'struct': 'TestIfStruct', 'data': { 'foo': 'int' },
-  'if': ['foo', ''] }
+  'if': ['foo', ' '] }