From: Ivan Maidanski Date: Wed, 28 Nov 2018 22:05:26 +0000 (+0300) Subject: Workaround 'var reassigned before old value use' cppcheck false positive X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=945afca717982db4363e6241a5da80a5999afed2;p=gc Workaround 'var reassigned before old value use' cppcheck false positive * 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. --- diff --git a/extra/AmigaOS.c b/extra/AmigaOS.c index d8311eed..1daaa0ac 100644 --- a/extra/AmigaOS.c +++ b/extra/AmigaOS.c @@ -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; diff --git a/pthread_support.c b/pthread_support.c index 61e0a10e..0ebe1b48 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -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