On 10/25/2016 08:41 AM, Eric Blake wrote: >>> +static void test_visitor_out_partial_visit(TestOutputVisitorData *data, >>> + const void *unused) >>> +{ >>> + /* Check that aborting mid-visit doesn't leak or double-free */ >>> + visit_start_struct(data->ov, NULL, NULL, 0, &error_abort); >>> + visit_start_struct(data->ov, "nested", NULL, 0, &error_abort); >>> + visitor_reset(data); >> >> Add a second test that additionally visits a member? Or is visiting the >> "nested" member enough? > > Visiting "nested" was enough to trigger the particular valgrind trace I > wanted, but more coverage never hurts. I'll send v2... > >> Would you be willing to do the same for lists and alternates? > > ...and it will also cover these.
Aborting in the middle of an alternate is trickier, since the current code for alternates does not allow a non-NULL *obj to visit_start_alternate() (that is, no virtual alternate walk is needed; to output an alternate, just call directly to the branch of interest, without a need to wrap things in visit_start/end_alternate; and on input, an alternate is currently useful only into a QAPI C struct). > >> >> Speaking of alternates, visitor.h's virtual walk example covers struct >> and list, but not alternate. > > Sounds like my v2 will be a longer series :) I'm still trying to see whether tweaking the docs to cover alternates makes much sense; we'll see what the patch looks like, but may decide it was not worth it. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature