aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qapi/common.py2
-rw-r--r--scripts/qapi/expr.py4
2 files changed, 3 insertions, 3 deletions
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index 3fb2fbe7d4..1724ac32db 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -204,7 +204,7 @@ def cgen_ifcond(ifcond: Union[str, Dict[str, Any]]) -> str:
if not ifcond:
return ''
if isinstance(ifcond, str):
- return ifcond
+ return 'defined(' + ifcond + ')'
oper, operands = next(iter(ifcond.items()))
if oper == 'not':
diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py
index 120b31089f..019f4c97aa 100644
--- a/scripts/qapi/expr.py
+++ b/scripts/qapi/expr.py
@@ -275,10 +275,10 @@ def check_if(expr: _JSONObject, info: QAPISourceInfo, source: str) -> None:
def _check_if(cond: Union[str, object]) -> None:
if isinstance(cond, str):
- if not cond.strip():
+ if not re.match(r'^[A-Z][A-Z0-9_]*$', cond):
raise QAPISemError(
info,
- "'if' condition '%s' of %s makes no sense"
+ "'if' condition '%s' of %s is not a valid identifier"
% (cond, source))
return