Re: [PATCH 01/14] viralloc: Adjust definition of VIR_FREE() for Coverity

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

 



On 01/22/2013 07:15 AM, John Ferlan wrote:
> The Coverity static analyzer was generating many false positives for the
> unary operation inside the VIR_FREE() definition as it was trying to evaluate
> the else portion of the "?:" even though the if portion was (1).

Simplifying VIR_FREE for Coverity is fine by me - we get the best of
both worlds: gcc compilation points out type mismatches, and Coverity
doesn't get confused with false positives.

> -# define VIR_FREE(ptr) virFree((void *) (1 ? (const void *) &(ptr) : (ptr)))
> +# if !STATIC_ANALYSIS
> +#  define VIR_FREE(ptr) virFree((void *) (1 ? (const void *) &(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 *) ((const void *) &(ptr)))

However, this is too complex.  It is sufficient to do:

#  define VIR_FREE(ptr) virFree((void *) &(ptr))

ACK with that change, so I'll go ahead and push it in your name.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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