[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v16 02/24] qapi: Guarantee NULL obj on input vis
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v16 02/24] qapi: Guarantee NULL obj on input visitor callback error |
Date: |
Fri, 29 Apr 2016 06:10:51 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 04/29/2016 02:28 AM, Markus Armbruster wrote:
> Eric Blake <address@hidden> writes:
>
>> Our existing input visitors were not very consistent on errors
>> in a function taking 'TYPE **obj' (that is, start_struct(),
>> start_alternate(), type_str(), and type_any(). next_list() is
>> similar, except that since commit 08f9541, it can't fail).
>
> Multiple sentences in a parenthesis, ugh :)
>
> Our existing input visitors were not very consistent on errors in a
> function taking 'TYPE **obj'. These are start_struct(),
> start_alternate(), type_str(), and type_any(). next_list() is
> similar, but can't fail (see commit since 08f9541).
>
> Can touch up on commit.
>
Yes, sounds better.
>> @@ -51,10 +57,16 @@ void visit_start_alternate(Visitor *v, const char *name,
>> GenericAlternate **obj, size_t size,
>> bool promote_int, Error **errp)
>> {
>> + Error *err = NULL;
>> +
>> assert(obj && size >= sizeof(GenericAlternate));
>> if (v->start_alternate) {
>> - v->start_alternate(v, name, obj, size, promote_int, errp);
>> + v->start_alternate(v, name, obj, size, promote_int, &err);
>> }
>> + if (v->type == VISITOR_INPUT) {
>> + assert(!err != !*obj);
>
> Could assert(v->start_alternate && !err != !*obj), to preempt "what if
> !v->start_alternate" worries. If you like that, I can do it on commit.
Can't hurt :)
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
[Qemu-devel] [PATCH v16 17/24] qmp: Add qmp_output_visitor_reset(), Eric Blake, 2016/04/28
[Qemu-devel] [PATCH v16 05/24] qapi: Consolidate QMP input visitor creation, Eric Blake, 2016/04/28
[Qemu-devel] [PATCH v16 09/24] qom: Wrap prop visit in visit_start_struct, Eric Blake, 2016/04/28
[Qemu-devel] [PATCH v16 11/24] qmp-input: Refactor when list is advanced, Eric Blake, 2016/04/28
[Qemu-devel] [PATCH v16 07/24] qmp-input: Don't consume input when checking has_member, Eric Blake, 2016/04/28