qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/7] qapi: support implicit structs in OptsVisit


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 1/7] qapi: support implicit structs in OptsVisitor
Date: Fri, 18 Sep 2015 06:26:52 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0

On 09/17/2015 02:30 PM, Eric Blake wrote:
> On 09/07/2015 06:08 AM, Kővágó, Zoltán wrote:
>> They are required for flat unions (you still have to allocate the
>> structs).
>>
>> Signed-off-by: Kővágó, Zoltán <address@hidden>
>> ---
>>  qapi/opts-visitor.c | 15 +++++++++++++++
>>  1 file changed, 15 insertions(+)
> 
> Reviewed-by: Eric Blake <address@hidden>
> 
> and required for 'make check' to pass when 4/7 is applied, so:
> 
> Tested-by: Eric Blake <address@hidden>
> 
>>
>> diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
>> index 7ae33b3..aa68814 100644
>> --- a/qapi/opts-visitor.c
>> +++ b/qapi/opts-visitor.c
>> @@ -149,6 +149,12 @@ opts_start_struct(Visitor *v, void **obj, const char 
>> *kind,
>>      }
>>  }
>>  
>> +static void
>> +opts_start_implicit_struct(Visitor *v, void **obj, size_t size, Error 
>> **errp)
>> +{
>> +    opts_start_struct(v, obj, NULL, NULL, size, errp);
> 
> Works because ov->depth is always non-zero by the time any visitor
> reaches this callback, triggering the early return in
> opts_start_struct().  Might be slightly safer if you just did the
> g_malloc0() here, to make sure no caller ever ends up re-initializing
> ov->unprocessed_opts, but what you have works.
> 

In fact, the alternative that just does a local malloc was proposed here:
https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg04746.html

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]