]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Remove need for STATIC_ANALYSIS check
authorJohn Ferlan <jferlan@redhat.com>
Tue, 17 May 2016 14:16:59 +0000 (10:16 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 19 May 2016 20:30:04 +0000 (16:30 -0400)
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.

src/util/viralloc.h

index d790b3dfb401829784494889b7959bd519ceb759..088f18f42548a0189863c3c2ced0633be1ec6353 100644 (file)
@@ -547,19 +547,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))
 
 
 /**
@@ -572,13 +564,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
 
 
 /**
@@ -589,13 +576,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)
 
 
 /**
@@ -606,12 +588,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);