qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables
Date: Fri, 19 Jul 2013 05:13:19 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7

On 07/19/2013 05:04 AM, Pawit Pornkitprasan wrote:
> On Fri, Jul 19, 2013 at 7:57 PM, Eric Blake <address@hidden> wrote:
>>
>> However, wouldn't it be nice if we improved the qapi generator to
>> guarantee a sane default value for optional parameters, even when
>> has_value is false?
>>
> 
> I'm not a qemu expert or anything, but wouldn't that destroy the point
> of has_value in the first place?

There are two uses for has_value.  One: on output, the user knows
whether the variable has been set to anything sane.  Two: on input, the
receiver knows if the caller passed an optional value.  For output,
has_value is always needed.  But for input, we could probably simplify a
LOT of code if 'value' already had a sane default of 0, without having
to first check 'has_value', instead of the current state where 'value'
must be treated as uninitialized if 'has_value' is false.  Improving the
qapi generator to guarantee 0 value of optional parameters that were not
specified in JSON should not block your patch (it would be a series by
itself), it's just a question of whether it is worth making the change
and the resulting simplifications we can make to code that can assume
sane default values.

-- 
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]