[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 01/25] qapi: Tighten QAPISchemaFOO.check() assertions
From: |
Markus Armbruster |
Subject: |
Re: [PATCH 01/25] qapi: Tighten QAPISchemaFOO.check() assertions |
Date: |
Tue, 24 Sep 2019 22:18:29 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) |
Eric Blake <address@hidden> writes:
> On 9/24/19 8:28 AM, Markus Armbruster wrote:
>> When we introduced the QAPISchema intermediate representation (commit
>> ac88219a6c7), we took a shortcut: we left check_exprs() & friends
>> alone instead of moving semantic checks into the
>> QAPISchemaFOO.check(). check_exprs() still checks and reports errors,
>> and the .check() assert check_exprs() did the job. There are a few
>> gaps, though.
>>
>> QAPISchemaArrayType.check() neglects to assert the element type is not
>> an array. Add the assertion.
>>
>> QAPISchemaObjectTypeVariants.check() neglects to assert the tag member
>> is not optional. Add the assertion.
>>
>> It neglects to assert the tag member is not conditional. Add the
>> assertion.
>>
>> It neglects to assert we actually have variants. Add the assertion.
>>
>> It asserts the variants are object types, but neglects to assert they
>> don't have variants. Tighten the assertion.
>>
>> QAPISchemaObjectTypeVariants.check_clash() has the same issue.
>> However, it can run only after .check(). Delete the assertion instead
>> of tightening it.
>>
>> QAPISchemaAlternateType.check() neglects to assert the branch types
>> don't conflict. Fixing that isn't trivial, so add just a TODO comment
>> for now. It'll be resolved later in this series.
>
> I'm guessing you found these by deleting check_exprs() and seeing what
> failed due to inadequate .check()
The first two or three I found by staring at the code. The remainder I
found when I moved checks from check_exprs() to .check() [PATCH 16]: any
check that doesn't replace an assertion means the assertion was missing.
>>
>> Signed-off-by: Markus Armbruster <address@hidden>
>> ---
>> scripts/qapi/common.py | 9 +++++++--
>> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> Reviewed-by: Eric Blake <address@hidden>
Thanks!
- [PATCH 00/25] qapi: Pay back some frontend technical debt, Markus Armbruster, 2019/09/24
- [PATCH 01/25] qapi: Tighten QAPISchemaFOO.check() assertions, Markus Armbruster, 2019/09/24
- [PATCH 03/25] qapi: New QAPISourceInfo, replacing dict, Markus Armbruster, 2019/09/24
- [PATCH 02/25] qapi: Rename .owner to .defined_in, Markus Armbruster, 2019/09/24
- [PATCH 10/25] qapi: Use check_name_str() where it suffices, Markus Armbruster, 2019/09/24
- [PATCH 17/25] qapi: Move context-free checking to the proper place, Markus Armbruster, 2019/09/24