aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2021-08-31 14:38:08 +0200
committerMarkus Armbruster <armbru@redhat.com>2021-09-03 17:09:10 +0200
commit6dcf03719acc4db6db7dc307359ff67d05e74451 (patch)
tree5eff7e580f36376d092750c6f63ddc85e6e5a823 /scripts
parent9c629fa8340792cd30758b65f0593d93d7a383d7 (diff)
downloadqemu-6dcf03719acc4db6db7dc307359ff67d05e74451.zip
qemu-6dcf03719acc4db6db7dc307359ff67d05e74451.tar.gz
qemu-6dcf03719acc4db6db7dc307359ff67d05e74451.tar.bz2
qapi: Tweak error messages for missing / conflicting meta-type
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210831123809.1107782-12-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qapi/expr.py23
1 files changed, 9 insertions, 14 deletions
diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py
index 9e2aa1d..ae4437b 100644
--- a/scripts/qapi/expr.py
+++ b/scripts/qapi/expr.py
@@ -630,20 +630,15 @@ def check_exprs(exprs: List[_JSONObject]) -> List[_JSONObject]:
if 'include' in expr:
continue
- if 'enum' in expr:
- meta = 'enum'
- elif 'union' in expr:
- meta = 'union'
- elif 'alternate' in expr:
- meta = 'alternate'
- elif 'struct' in expr:
- meta = 'struct'
- elif 'command' in expr:
- meta = 'command'
- elif 'event' in expr:
- meta = 'event'
- else:
- raise QAPISemError(info, "expression is missing metatype")
+ metas = expr.keys() & {'enum', 'struct', 'union', 'alternate',
+ 'command', 'event'}
+ if len(metas) != 1:
+ raise QAPISemError(
+ info,
+ "expression must have exactly one key"
+ " 'enum', 'struct', 'union', 'alternate',"
+ " 'command', 'event'")
+ meta = metas.pop()
check_name_is_str(expr[meta], info, "'%s'" % meta)
name = cast(str, expr[meta])