Seems recent versions of Coverity have (mostly) resolved the issue using
ternary operations in VIR_FREE (and now VIR_DISPOSE*) macros. So let's
just remove it and if necessary handle one off issues as the arise.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/util/viralloc.h | 34 ++++++----------------------------
1 file changed, 6 insertions(+), 28 deletions(-)
diff --git a/src/util/viralloc.h b/src/util/viralloc.h
index 5f4e27b..008f58e 100644
--- a/src/util/viralloc.h
+++ b/src/util/viralloc.h
@@ -550,19 +550,11 @@ void virDispose(void *ptrptr, size_t count, size_t element_size,
size_t *countpt
*
* This macro is safe to use on arguments with side effects.
*/
-# if !STATIC_ANALYSIS
/* The ternary ensures that ptr is a non-const pointer and not an
* integer type, all while evaluating ptr only once. This gives us
* extra compiler safety when compiling under gcc.
*/
-# define VIR_FREE(ptr) virFree(1 ? (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(&(ptr))
-# endif
+# define VIR_FREE(ptr) virFree(1 ? (void *) &(ptr) : (ptr))
/**
@@ -575,13 +567,8 @@ void virDispose(void *ptrptr, size_t count, size_t element_size,
size_t *countpt
*
* This macro is safe to use on arguments with side effects.
*/
-# if !STATIC_ANALYSIS
-/* See explanation in VIR_FREE */
-# define VIR_DISPOSE_N(ptr, count) virDispose(1 ? (void *) &(ptr) : (ptr), 0, \
+# define VIR_DISPOSE_N(ptr, count) virDispose(1 ? (void *) &(ptr) : (ptr), 0, \
sizeof(*(ptr)), &(count))
-# else
-# define VIR_DISPOSE_N(ptr, count) virDispose(&(ptr), 0, sizeof(*(ptr)),
&(count))
-# endif
/**
@@ -592,13 +579,8 @@ void virDispose(void *ptrptr, size_t count, size_t element_size,
size_t *countpt
*
* This macro is not safe to be used on arguments with side effects.
*/
-# if !STATIC_ANALYSIS
-/* See explanation in VIR_FREE */
-# define VIR_DISPOSE_STRING(ptr) virDispose(1 ? (void *) &(ptr) : (ptr), \
- (ptr) ? strlen((ptr)) : 0, 1, NULL)
-# else
-# define VIR_DISPOSE_STRING(ptr) virDispose(&(ptr), (ptr) ? strlen((ptr)) : 1,
NULL)
-# endif
+# define VIR_DISPOSE_STRING(ptr) virDispose(1 ? (void *) &(ptr) : (ptr), \
+ (ptr) ? strlen((ptr)) : 0, 1, NULL)
/**
@@ -609,12 +591,8 @@ void virDispose(void *ptrptr, size_t count, size_t element_size,
size_t *countpt
*
* This macro is safe to be used on arguments with side effects.
*/
-# if !STATIC_ANALYSIS
-/* See explanation in VIR_FREE */
-# define VIR_DISPOSE(ptr) virDispose(1 ? (void *) &(ptr) : (ptr), 1, sizeof(*(ptr)),
NULL)
-# else
-# define VIR_DISPOSE(ptr) virDispose(&(ptr), 1, sizeof(*(ptr)), NULL)
-# endif
+# define VIR_DISPOSE(ptr) virDispose(1 ? (void *) &(ptr) : (ptr), 1, \
+ sizeof(*(ptr)), NULL)
void virAllocTestInit(void);
--
2.5.5