[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 29/37] qapi: Reject blank 'if' conditions in addition to empty one
From: |
Markus Armbruster |
Subject: |
[PULL 29/37] qapi: Reject blank 'if' conditions in addition to empty ones |
Date: |
Tue, 24 Sep 2019 14:33:26 +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 <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
scripts/qapi/common.py | 5 +++--
tests/qapi-schema/bad-if-list.err | 2 +-
tests/qapi-schema/bad-if-list.json | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index a58e904978..2b46164854 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -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:
diff --git a/tests/qapi-schema/bad-if-list.err
b/tests/qapi-schema/bad-if-list.err
index 0af6316f78..53af099083 100644
--- a/tests/qapi-schema/bad-if-list.err
+++ b/tests/qapi-schema/bad-if-list.err
@@ -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
diff --git a/tests/qapi-schema/bad-if-list.json
b/tests/qapi-schema/bad-if-list.json
index 49ced9b9ca..ea3d95bb6b 100644
--- a/tests/qapi-schema/bad-if-list.json
+++ b/tests/qapi-schema/bad-if-list.json
@@ -1,3 +1,3 @@
# check invalid 'if' content
{ 'struct': 'TestIfStruct', 'data': { 'foo': 'int' },
- 'if': ['foo', ''] }
+ 'if': ['foo', ' '] }
--
2.21.0
- [PULL 00/37] QAPI patches for 2019-09-24, Markus Armbruster, 2019/09/24
- [PULL 02/37] make check-unit: use after free in test-opts-visitor, Markus Armbruster, 2019/09/24
- [PULL 04/37] qapi: Drop check_type()'s redundant parameter @allow_optional, Markus Armbruster, 2019/09/24
- [PULL 01/37] qapi: Make visit_next_list()'s comment less confusing, Markus Armbruster, 2019/09/24
- [PULL 07/37] tests/qapi-schema: Demonstrate bad reporting of funny characters, Markus Armbruster, 2019/09/24
- [PULL 05/37] qapi: Drop support for boxed alternate arguments, Markus Armbruster, 2019/09/24
- [PULL 06/37] docs/devel/qapi-code-gen: Minor specification fixes, Markus Armbruster, 2019/09/24
- [PULL 11/37] qapi: Permit alternates with just one branch, Markus Armbruster, 2019/09/24
- [PULL 19/37] tests/qapi-schema: Cover unknown pragma, Markus Armbruster, 2019/09/24
- [PULL 29/37] qapi: Reject blank 'if' conditions in addition to empty ones,
Markus Armbruster <=
- [PULL 35/37] qapi: Fix to .check() empty structs just once, Markus Armbruster, 2019/09/24
- [PULL 33/37] qapi: Clean up around check_known_keys(), Markus Armbruster, 2019/09/24
- [PULL 32/37] qapi: Simplify check_keys(), Markus Armbruster, 2019/09/24
- [PULL 34/37] qapi: Delete useless check_exprs() code for simple union kind, Markus Armbruster, 2019/09/24
- [PULL 27/37] qapi: Remove null from schema language, Markus Armbruster, 2019/09/24
- [PULL 13/37] qapi: Adjust frontend errors to say enum value, not member, Markus Armbruster, 2019/09/24
- [PULL 26/37] qapi: Improve reporting of lexical errors, Markus Armbruster, 2019/09/24
- [PULL 10/37] qapi: Permit 'boxed' with empty type, Markus Armbruster, 2019/09/24
- [PULL 37/37] qapi: Assert .visit() and .check_clash() run only after .check(), Markus Armbruster, 2019/09/24
- [PULL 22/37] tests/qapi-schema: Demonstrate broken discriminator errors, Markus Armbruster, 2019/09/24