mirror of https://gitee.com/openkylin/qemu.git
qapi: Tweak error messages for unknown / conflicting 'if' keys
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210831123809.1107782-13-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
6dcf03719a
commit
34f7b25e57
|
@ -286,13 +286,12 @@ def _check_if(cond: Union[str, object]) -> None:
|
||||||
raise QAPISemError(
|
raise QAPISemError(
|
||||||
info,
|
info,
|
||||||
"'if' condition of %s must be a string or an object" % source)
|
"'if' condition of %s must be a string or an object" % source)
|
||||||
|
check_keys(cond, info, "'if' condition of %s" % source, [],
|
||||||
|
["all", "any", "not"])
|
||||||
if len(cond) != 1:
|
if len(cond) != 1:
|
||||||
raise QAPISemError(
|
raise QAPISemError(
|
||||||
info,
|
info,
|
||||||
"'if' condition dict of %s must have one key: "
|
"'if' condition of %s has conflicting keys" % source)
|
||||||
"'all', 'any' or 'not'" % source)
|
|
||||||
check_keys(cond, info, "'if' condition", [],
|
|
||||||
["all", "any", "not"])
|
|
||||||
|
|
||||||
oper, operands = next(iter(cond.items()))
|
oper, operands = next(iter(cond.items()))
|
||||||
if not operands:
|
if not operands:
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
bad-if-key.json: In struct 'TestIfStruct':
|
bad-if-key.json: In struct 'TestIfStruct':
|
||||||
bad-if-key.json:2: 'if' condition has unknown key 'value'
|
bad-if-key.json:2: 'if' condition of struct has unknown key 'value'
|
||||||
Valid keys are 'all', 'any', 'not'.
|
Valid keys are 'all', 'any', 'not'.
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
bad-if-keys.json: In struct 'TestIfStruct':
|
bad-if-keys.json: In struct 'TestIfStruct':
|
||||||
bad-if-keys.json:2: 'if' condition dict of struct must have one key: 'all', 'any' or 'not'
|
bad-if-keys.json:2: 'if' condition of struct has conflicting keys
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
enum-if-invalid.json: In enum 'TestIfEnum':
|
enum-if-invalid.json: In enum 'TestIfEnum':
|
||||||
enum-if-invalid.json:2: 'if' condition has unknown key 'val'
|
enum-if-invalid.json:2: 'if' condition of 'data' member 'bar' has unknown key 'val'
|
||||||
Valid keys are 'all', 'any', 'not'.
|
Valid keys are 'all', 'any', 'not'.
|
||||||
|
|
Loading…
Reference in New Issue