Re: [PATCHv2 06/17] qemu: implement <model> subelement to <controller>

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

 




On 07/22/2015 04:18 PM, Laine Stump wrote:
> On 07/22/2015 03:54 PM, John Ferlan wrote:
...

>>> +                if (deviceName &&
>>> +                    VIR_STRDUP(options->type, deviceName) < 0)
>>> +                    goto cleanup;
>>> +
>> As has been told to me before - virStrdup/VIR_STRDUP is "tolerant" of
>> deviceName == NULL returning 0 if it's NULL, so just:
>>
>>     if (VIR_STRDUP(options->type, deviceName) < 0)
>>         goto cleanup;
>>
>> is necessary
> 
> But that would set options->type to NULL in the case that deviceName
> hadn't been set, and we don't want that. Consider for a moment that
> options->type had already been explicitly set to "pci-bridge". Since
> options->type != NULL, deviceName would remain NULL, we would get to the
> VIR_STRDUP() and unconditionally set options->type to NULL, losing the
> value that we actually wanted (and leaking it to boot).
> 
> Hmm. I guess my logic *is* a bit backwards though :-) Instead I should
> say "if (!options->type && VIR_STRDUP(blah)...)"
> 

Oh right.  I'm fine with (!options->type checking since that's what
you're trying to not overwrite

John

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]