[libvirt] [PATCH 4/4] virFree: Check const correctness
Eric Blake
eblake at redhat.com
Tue Jul 15 20:08:22 UTC 2014
On 07/15/2014 07:46 AM, Eric Blake wrote:
> But if you take my suggestion in 2/4 about merely removing the
> 'cast-away-const' while still keeping type safety, then a
> single-argument virFree() should still be noisy on attempts to VIR_FREE
> a const pointer.
>
>
>> @@ -543,11 +543,23 @@ void virFree(void *ptrptr) ATTRIBUTE_NONNULL(1);
>> * @ptr: pointer holding address to be freed
>> *
>> * Free the memory stored in 'ptr' and update to point
>> - * to NULL.
>> + * to NULL. Moreover, this macro has a side effect in
>> + * form of evaluating passed argument multiple times.
>
> NACK. I think it is possible to use sizeof() to come up with a
> construct that will only do side effects once, rather than having to
> weaken the guarantee of VIR_FREE. Please give me some time to propose
> an alternative.
I didn't even need to resort to sizeof(). Here's v2, which replaces 2,
3, and 4 of this series:
https://www.redhat.com/archives/libvir-list/2014-July/msg00760.html
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140715/73c09e1d/attachment-0001.sig>
More information about the libvir-list
mailing list