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

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

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)))
> +#  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

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