[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 13/28] qapi: Add new clone visitor
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH v4 13/28] qapi: Add new clone visitor |
Date: |
Fri, 03 Jun 2016 16:04:36 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Markus Armbruster <address@hidden> writes:
> Eric Blake <address@hidden> writes:
[...]
>> diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
>> index 279ea8e..c5bdca2 100644
>> --- a/qapi/qapi-visit-core.c
>> +++ b/qapi/qapi-visit-core.c
[...]
>> @@ -44,10 +44,10 @@ void visit_start_struct(Visitor *v, const char *name,
>> void **obj,
>>
>> if (obj) {
>> assert(size);
>> - assert(v->type != VISITOR_OUTPUT || *obj);
>> + assert(!(v->type & VISITOR_OUTPUT) || *obj);
>> }
>
> For real walks (obj != NULL):
>
> * Input visitors write *obj, and don't care for the old value.
>
> * Output visitors read *obj, and a struct can't be null.
>
> * The dealloc visitor reads *obj, but null is fine (partially
> constructed object).
>
> * The clone visitor reads like an output visitor (except at the root)
> and writes like an input visitor.
>
> Before the patch, we assert "if output visitor, then *obj isn't null".
>
> After the patch, we do the same for the clone visitor. Correct, except
> at the root. There, @obj points to qapi_clone()'s @dst, which is
> uninitialized. I'm afraid this assertion fails if @dst happens to be
> null.
I can observe this failure in make check when I compile with
optimization.
[...]