Re: [PATCH 2/4] viralloc: Honor const correctness in VIR_FREE

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

 




On 07/15/2014 09:41 AM, Eric Blake wrote:

<...snip...>

> 
> This definition was doing two things - casting away const, AND doing
> type validation.  virFree(&foo) will compile even if foo is an int, but
> we want to ensure that foo is of type char*.
> 
> I think what you want is:
> 
> #  define VIR_FREE(ptr) virFree(1 ? &(ptr) : (ptr))
> 
>> -# else
>> -/* The Coverity static analyzer considers the else path of the "?:" and
>> - * flags the VIR_FREE() of the address of the address of memory as a
>> - * RESOURCE_LEAK resulting in numerous false positives (eg, VIR_FREE(&ptr))
>> - */
>> -#  define VIR_FREE(ptr) virFree((void *) &(ptr))
> 
> and keep this alternative to hush up coverity.
> 
> 

FWIW: I got notice a couple weeks ago that Coverity 7.5.0 (released June
27, 2014) has a fix for this issue.

Since there's no "guarantee" that everyone who runs a Coverity scan will
update to that new version - I'd be hesitant to say that we could just
do away with it since without this "condition"- Coverity will be very noisy.

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]