[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 19/25] qapi: Improve reporting of invalid flags
From: |
Eric Blake |
Subject: |
Re: [PATCH 19/25] qapi: Improve reporting of invalid flags |
Date: |
Tue, 24 Sep 2019 13:07:22 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 |
On 9/24/19 8:28 AM, Markus Armbruster wrote:
> Split check_flags() off check_keys() and have check_exprs() call it
> later, so its error messages gain an "in definition" line. Tweak the
> error messages.
>
> Checking values in a function named check_keys() is unclean anyway.
>
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
> scripts/qapi/common.py | 22 ++++++++++++----------
> tests/qapi-schema/allow-preconfig-test.err | 3 ++-
> tests/qapi-schema/args-bad-boxed.err | 3 ++-
> tests/qapi-schema/oob-test.err | 3 ++-
> tests/qapi-schema/type-bypass-bad-gen.err | 3 ++-
> 5 files changed, 20 insertions(+), 14 deletions(-)
>
> +
> +def check_flags(expr, info):
> + for key in ['gen', 'success-response']:
> + if key in expr and expr[key] is not False:
Is it any more pythonic and/or a micro-optimization to compress this to:
if expr.get(key, False) is not False:
> + raise QAPISemError(
> + info, "flag '%s' may only use false value" % key)
> + for key in ['boxed', 'allow-oob', 'allow-preconfig']:
> + if key in expr and expr[key] is not True:
and here too.
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [PATCH 07/25] qapi: Improve reporting of member name clashes, (continued)
- [PATCH 13/25] qapi: Make check_type()'s array case a bit more obvious, Markus Armbruster, 2019/09/24
- [PATCH 18/25] qapi: Improve reporting of invalid 'if' errors, Markus Armbruster, 2019/09/24
- [PATCH 12/25] qapi: Move check for reserved names out of add_name(), Markus Armbruster, 2019/09/24
- [PATCH 22/25] qapi: Eliminate check_keys(), rename check_known_keys(), Markus Armbruster, 2019/09/24
- [PATCH 19/25] qapi: Improve reporting of invalid flags, Markus Armbruster, 2019/09/24
- Re: [PATCH 19/25] qapi: Improve reporting of invalid flags,
Eric Blake <=
- [PATCH 20/25] qapi: Improve reporting of missing / unknown definition keys, Markus Armbruster, 2019/09/24
- [PATCH 05/25] qapi: Clean up member name case checking, Markus Armbruster, 2019/09/24
- [PATCH 23/25] qapi: Improve reporting of missing documentation comment, Markus Armbruster, 2019/09/24