[Top][All Lists]

[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

>                                            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.

reply via email to

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