Eric Blake <ebl...@redhat.com> writes: > On 04/14/2016 09:22 AM, Markus Armbruster wrote: >> Eric Blake <ebl...@redhat.com> 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. [...]