]> granicus.if.org Git - gc/commitdiff
Workaround 'var reassigned before old value use' cppcheck false positive
authorIvan Maidanski <ivmai@mail.ru>
Wed, 28 Nov 2018 22:05:26 +0000 (01:05 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 28 Nov 2018 22:08:09 +0000 (01:08 +0300)
* extra/AmigaOS.c [!GC_AMIGA_ONLYFAST && CPPCHECK]
(GC_amiga_allocwrapper_any): Add a dummy read of GC_amiga_dontalloc
global variable; add comment.
* pthread_support.c [CPPCHECK] (GC_do_blocking_inner): Add a dummy read
of thread_blocked field of GC_thread.
* pthread_support.c [CPPCHECK] (GC_call_with_gc_active): Add a dummy
read of traced_stack_sect field of GC_thread.

extra/AmigaOS.c
pthread_support.c

index d8311eed4c6fde58899777ffe5b759db6633e3e6..1daaa0aca851f8d39e2ed6bcd3e47e3166e30fc0 100644 (file)
@@ -425,6 +425,9 @@ void *GC_amiga_allocwrapper_any(size_t size,void *(*AllocFunction)(size_t size2)
 #endif
         }
 
+#   if defined(CPPCHECK)
+      if (GC_amiga_dontalloc) /* variable is actually used by AllocFunction */
+#   endif
         GC_amiga_dontalloc=FALSE;
 
         return ret;
index 61e0a10efcd673486829501b189a4a4e83d7c540..0ebe1b4855f739cb6c6114da9f3d4af6ee8031bf 100644 (file)
@@ -1392,6 +1392,9 @@ GC_INNER void GC_do_blocking_inner(ptr_t data, void * context GC_ATTR_UNUSED)
     UNLOCK();
     d -> client_data = (d -> fn)(d -> client_data);
     LOCK();   /* This will block if the world is stopped.       */
+#   if defined(CPPCHECK)
+      GC_noop1((unsigned)me->thread_blocked);
+#   endif
     me -> thread_blocked = FALSE;
 #   if defined(GC_DARWIN_THREADS) && !defined(DARWIN_DONT_PARSE_STACK)
         if (topOfStackUnset)
@@ -1455,6 +1458,9 @@ GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
     GC_ASSERT(me -> traced_stack_sect == &stacksect);
 
     /* Restore original "stack section".        */
+#   if defined(CPPCHECK)
+      GC_noop1((word)me->traced_stack_sect);
+#   endif
     LOCK();
     me -> traced_stack_sect = stacksect.prev;
 #   ifdef IA64