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

Re: [libvirt] [PATCH] Don't free NULL network in cmdNetworkUpdate



On 27.08.2013 14:07, Eric Blake wrote:
> On 08/27/2013 06:03 AM, Laine Stump wrote:
>> On 08/26/2013 09:39 AM, Ján Tomko wrote:
>>> If the network has not been found, virNetworkFree(NULL)
>>> was called, resulting in an extra error:
>>> error: invalid network pointer in virNetworkFree
>>
>>
>> The patch is okay, but all vir*Free() functions should be NOPs when the
>> argument is NULL.
> 
> All _internal_ vir*Free functions should be NOPs.  All public vir*Free
> APIs (including virNetworkFree) are documented to explicitly fail on
> NULL arguments (more precisely, on any argument not created by an
> earlier API call), and we cannot change that behavior as it would be an
> API change that violates back-compat.

Why it would break backward compatibility? I think it will break forward
compatibility instead (which we don't care about). That is, currently
apps have to use:

virXPtr obj = NULL;

obj = virLookupBy..();

... do something with obj;

ret = 0;
cleanup:
if (obj)
  virXFree(obj);


However, if virXFree would accept NULL, it won't affect older
applications, while new can just:

cleanup:
virXFree(obj);

But then again, this is forward compatibility (the code won't work with
downgraded libvirtd) - but who cares?

Michal


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