[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v15 22/23] qapi: Simplify semantics of visit_nex
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v15 22/23] qapi: Simplify semantics of visit_next_list() |
Date: |
Thu, 28 Apr 2016 09:44:26 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 04/27/2016 06:01 PM, Eric Blake wrote:
> The semantics of the list visit are somewhat baroque, with the
> following pseudocode when FooList is used:
>
>
> We can greatly simplify things by hoisting the special case
> into the start() routine, and flipping the order in the loop
> to visit before advance:
>
> start(head)
> for (tail = *head; tail; tail = next(tail)) {
> visit(&tail->value)
> }
>
> +++ b/qapi/qapi-visit-core.c
> @@ -48,15 +48,17 @@ void visit_end_struct(Visitor *v)
> v->end_struct(v);
> }
>
> -void visit_start_list(Visitor *v, const char *name, Error **errp)
> +void visit_start_list(Visitor *v, const char *name, GenericList **list,
> + size_t size, Error **errp)
> {
> - v->start_list(v, name, errp);
> + assert(!list || size >= sizeof(GenericList));
> + v->start_list(v, name, list, size, errp);
> }
As mentioned in 02/23, this would be a good place to assert that:
if (v->type == VISITOR_INPUT) {
assert(!(err && *list));
}
of course, that means declaring a local 'err'.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH v15 15/23] qmp: Support explicit null during visits, (continued)
- [Qemu-devel] [PATCH v15 12/23] qapi: Document visitor interfaces, add assertions, Eric Blake, 2016/04/27
- [Qemu-devel] [PATCH v15 18/23] qmp: Tighten output visitor rules, Eric Blake, 2016/04/27
- [Qemu-devel] [PATCH v15 17/23] qmp: Add qmp_output_visitor_reset(), Eric Blake, 2016/04/27
- [Qemu-devel] [PATCH v15 20/23] tests/string-input-visitor: Add negative integer tests, Eric Blake, 2016/04/27
- [Qemu-devel] [PATCH v15 21/23] qapi: Fix string input visitor handling of invalid list, Eric Blake, 2016/04/27
- [Qemu-devel] [PATCH v15 19/23] qapi: Split visit_end_struct() into pieces, Eric Blake, 2016/04/27
- [Qemu-devel] [PATCH v15 22/23] qapi: Simplify semantics of visit_next_list(), Eric Blake, 2016/04/27
- Re: [Qemu-devel] [PATCH v15 22/23] qapi: Simplify semantics of visit_next_list(),
Eric Blake <=
- [Qemu-devel] [PATCH v15 16/23] spapr_drc: Expose 'null' in qom-get when there is no fdt, Eric Blake, 2016/04/27
- [Qemu-devel] [PATCH v15 23/23] qapi: Change visit_type_FOO() to no longer return partial objects, Eric Blake, 2016/04/27
- Re: [Qemu-devel] [PATCH v15 00/23] qapi visitor cleanups (post-introspection cleanups subset E), Markus Armbruster, 2016/04/28