[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v14 08/19] qapi: Document visitor interfaces, ad
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH v14 08/19] qapi: Document visitor interfaces, add assertions |
Date: |
Thu, 28 Apr 2016 18:33:53 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Eric Blake <address@hidden> writes:
> On 04/14/2016 09:22 AM, Markus Armbruster wrote:
>> Eric Blake <address@hidden> writes:
[...]
>>> +++ b/qapi/qapi-visit-core.c
>>> @@ -23,6 +23,10 @@
>>> void visit_start_struct(Visitor *v, const char *name, void **obj,
>>> size_t size, Error **errp)
>>> {
>>> + if (obj) {
>>> + assert(size);
>>
>> Yes, because the generator puts a dummy member into empty structs.
>>
>>> + assert(v->type != VISITOR_OUTPUT || *obj);
>>
>> Can you point me to the spot in the contract that requires this?
>
> Translation of the assert: If you are using an output visitor, and not
> doing a virtual walk (obj is non-NULL), then the object must be
> completely built (*obj is non-NULL). For an input visitor, *obj is NULL
> on entry (we're allocating it, after all);
Actually, it may be anything, including uninitialized, and it'll be
overwritten.
> for the dealloc visitor, *obj
> may or may not be NULL (since we handle cleanup of partial allocation).
Got the assertion now, thanks!
> In the text, "output visitors (QMP and string) take a completed QAPI
> graph", but maybe I can further clarify that a completed object means
> that *obj is non-NULL and all 'has_member' and 'member' members are
> complete.
[...]
- [Qemu-devel] [PATCH v14 13/19] qmp: Tighten output visitor rules, (continued)
[Qemu-devel] [PATCH v14 16/19] qom: Wrap prop visit in visit_start_struct, Eric Blake, 2016/04/08
[Qemu-devel] [PATCH v14 08/19] qapi: Document visitor interfaces, add assertions, Eric Blake, 2016/04/08
[Qemu-devel] [PATCH v14 10/19] qapi: Add visit_type_null() visitor, Eric Blake, 2016/04/08
[Qemu-devel] [PATCH v14 18/19] qapi: Simplify semantics of visit_next_list(), Eric Blake, 2016/04/08
[Qemu-devel] [PATCH v14 17/19] qmp-input: Require struct push to visit members of top dict, Eric Blake, 2016/04/08