Workaround 'condition is always true' cppcheck style warnings in GC_init
authorIvan Maidanski <ivmai@mail.ru>
Thu, 22 Dec 2016 22:44:06 +0000 (01:44 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 22 Dec 2016 22:44:06 +0000 (01:44 +0300)
* misc.c (GC_init): Skip GC_STATIC_ASSERT for sizeof(ptr_t),
sizeof(word), (word)-1>(word)0 and ((signed_word)-1)<0 if CPPCHECK.

misc.c

diff --git a/misc.c b/misc.c
index 16a833a..a9b6a2b 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -1184,21 +1184,21 @@ GC_API void GC_CALL GC_init(void)
 #       endif
       }
 #   endif
-    GC_STATIC_ASSERT(sizeof (ptr_t) == sizeof(word));
 #   if !defined(CPPCHECK)
+      GC_STATIC_ASSERT(sizeof(ptr_t) == sizeof(word));
       GC_STATIC_ASSERT(sizeof(signed_word) == sizeof(word));
+#     if !defined(_AUX_SOURCE) || defined(__GNUC__)
+        GC_STATIC_ASSERT((word)(-1) > (word)0);
+        /* word should be unsigned */
+#     endif
+      /* We no longer check for ((void*)(-1) > NULL) since all pointers */
+      /* are explicitly cast to word in every less/greater comparison.  */
+      GC_STATIC_ASSERT((signed_word)(-1) < (signed_word)0);
 #   endif
     GC_STATIC_ASSERT(sizeof (struct hblk) == HBLKSIZE);
 #   ifndef THREADS
       GC_ASSERT(!((word)GC_stackbottom HOTTER_THAN (word)GC_approx_sp()));
 #   endif
-#   if !defined(_AUX_SOURCE) || defined(__GNUC__)
-      GC_STATIC_ASSERT((word)(-1) > (word)0);
-      /* word should be unsigned */
-#   endif
-    /* We no longer check for ((void*)(-1) > NULL) since all pointers   */
-    /* are explicitly cast to word in every less-greater comparison.    */
-    GC_STATIC_ASSERT((signed_word)(-1) < (signed_word)0);
 #   ifndef GC_DISABLE_INCREMENTAL
       if (GC_incremental || 0 != GETENV("GC_ENABLE_INCREMENTAL")) {
         /* For GWW_VDB on Win32, this needs to happen before any        */