qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 5/5] qapi: Fix bogus error for 'if': { 'not': '' }


From: Markus Armbruster
Subject: Re: [PATCH 5/5] qapi: Fix bogus error for 'if': { 'not': '' }
Date: Wed, 08 Sep 2021 15:27:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Markus Armbruster <armbru@redhat.com> writes:

> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  scripts/qapi/expr.py             | 21 +++++++++++++--------
>  tests/qapi-schema/bad-if-not.err |  2 +-
>  2 files changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py
> index b62f0a3640..ad3732c7f0 100644
> --- a/scripts/qapi/expr.py
> +++ b/scripts/qapi/expr.py
> @@ -293,17 +293,22 @@ def _check_if(cond: Union[str, object]) -> None:
>                  info,
>                  "'if' condition of %s has conflicting keys" % source)
>  
> -        oper, operands = next(iter(cond.items()))
> +        if 'not' in cond:
> +            _check_if(cond['not'])
> +        elif 'all' in cond:
> +            _check_infix('all', cond['all'])
> +        else:
> +            _check_infix('any', cond['any'])
> +
> +    def _check_infix(operator: str, operands: object):
> +        if not isinstance(operands, list):
> +            raise QAPISemError(
> +                info,
> +                "'%s' condition of %s must be an array"
> +                % (operator, source))
>          if not operands:
>              raise QAPISemError(
>                  info, "'if' condition [] of %s is useless" % source)
> -
> -        if oper == "not":
> -            _check_if(operands)
> -            return
> -        if oper in ("all", "any") and not isinstance(operands, list):
> -            raise QAPISemError(
> -                info, "'%s' condition of %s must be an array" % (oper, 
> source))
>          for operand in operands:
>              _check_if(operand)
>  
> diff --git a/tests/qapi-schema/bad-if-not.err 
> b/tests/qapi-schema/bad-if-not.err
> index b3acdd679a..b33f5e16b8 100644
> --- a/tests/qapi-schema/bad-if-not.err
> +++ b/tests/qapi-schema/bad-if-not.err
> @@ -1,2 +1,2 @@
>  bad-if-not.json: In struct 'TestIfStruct':
> -bad-if-not.json:2: 'if' condition [] of struct is useless
> +bad-if-not.json:2: 'if' condition '' of struct is not a valid identifier

Squashing in this fixup:

diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py
index ad3732c7f0..90bde501b0 100644
--- a/scripts/qapi/expr.py
+++ b/scripts/qapi/expr.py
@@ -300,7 +300,7 @@ def _check_if(cond: Union[str, object]) -> None:
         else:
             _check_infix('any', cond['any'])
 
-    def _check_infix(operator: str, operands: object):
+    def _check_infix(operator: str, operands: object) -> None:
         if not isinstance(operands, list):
             raise QAPISemError(
                 info,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]