[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 08/13] qapi: Assert output visitors see only valid enum value
From: |
Markus Armbruster |
Subject: |
Re: [PATCH 08/13] qapi: Assert output visitors see only valid enum values |
Date: |
Fri, 24 Apr 2020 09:31:49 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) |
Eric Blake <address@hidden> writes:
> On 4/23/20 11:00 AM, Markus Armbruster wrote:
>> output_type_enum() fails when *obj is not a valid value of the enum
>> type. Should not happen. Drop the check, along with its unit tests.
>> qapi_enum_lookup()'s assertion still guards.
>>
>> Signed-off-by: Markus Armbruster <address@hidden>
>> ---
>> qapi/qapi-visit-core.c | 9 -------
>> tests/test-qobject-output-visitor.c | 39 -----------------------------
>> tests/test-string-output-visitor.c | 19 --------------
>> 3 files changed, 67 deletions(-)
>
> Nice cleanup.
>
> The commit message implies adding an assertion; but in reality, the
> change is deleting dead code (because we already have the assertion in
> place). Maybe it's worth updating the subject?
I tried to say it in the body: "qapi_enum_lookup()'s assertion still
guards." I could replace that by "This unmasks qapi_enum_lookup()'s
assertion." Okay? Better ideas?
> Reviewed-by: Eric Blake <address@hidden>
>
>> - /*
>> - * TODO why is this an error, not an assertion? If assertion:
>> - * delete, and rely on qapi_enum_lookup()
>> - */
>> - if (value < 0 || value >= lookup->size) {
>> - error_setg(errp, QERR_INVALID_PARAMETER, name ? name : "null");
>> - return;
>> - }
>
> The comment being deleted is what points out the assertion that
> already exists.
Thanks!
- [PATCH 10/13] qapi: Clean up visitor's recovery from input with invalid type, (continued)
- [PATCH 04/13] qapi: Document @errp usage more thoroughly in visitor.h, Markus Armbruster, 2020/04/23
- [PATCH 03/13] qapi: Fix typo in visit_start_list()'s contract, Markus Armbruster, 2020/04/23
- [PATCH 08/13] qapi: Assert output visitors see only valid enum values, Markus Armbruster, 2020/04/23
- [PATCH 13/13] qom: Simplify object_property_get_enum(), Markus Armbruster, 2020/04/23
- [PATCH 11/13] qapi: Assert non-input visitors see only valid alternate tags, Markus Armbruster, 2020/04/23
- [PATCH 05/13] qapi: Polish prose in visitor.h, Markus Armbruster, 2020/04/23
- [PATCH 12/13] qapi: Only input visitors can actually fail, Markus Armbruster, 2020/04/23
- [PATCH 09/13] qapi: Assert non-input visitors see only valid narrow integers, Markus Armbruster, 2020/04/23