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

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

 



Since we've corrected all the callers that passed a const pointer to
VIR_FREE() we may drop the typecasting horribility and let the macro
be a simple wrapper over the virFree() function.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/util/viralloc.h | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/src/util/viralloc.h b/src/util/viralloc.h
index 7125e67..71b4a45 100644
--- a/src/util/viralloc.h
+++ b/src/util/viralloc.h
@@ -547,20 +547,7 @@ void virFree(void *ptrptr) ATTRIBUTE_NONNULL(1);
  *
  * This macro is safe to use on arguments with side effects.
  */
-# if !STATIC_ANALYSIS
-/* The ternary ensures that ptr is a pointer and not an integer type,
- * while evaluating ptr only once.  This gives us extra compiler
- * safety when compiling under gcc.  For now, we intentionally cast
- * away const, since a number of callers safely pass const char *.
- */
-#  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 *) &(ptr))
-# endif
+# define VIR_FREE(ptr) virFree(&(ptr))
 
 void virAllocTestInit(void);
 int virAllocTestCount(void);
-- 
1.8.5.5

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