Workaround 'condition is always false' cppcheck warning in get_next_stack
authorIvan Maidanski <ivmai@mail.ru>
Tue, 25 Oct 2016 08:37:40 +0000 (11:37 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 25 Oct 2016 08:38:31 +0000 (11:38 +0300)
* win32_threads.c [CPPCHECK] (GC_get_next_stack): Set thread a non-null
value (near current_min assignment) even if GC_win32_dll_threads (to
avoid cppcheck complain that if(thread!=0) is always false (thus
UNPROTECT_THREAD(thread) is never reached) if GC_DISCOVER_TASK_THREADS.

win32_threads.c

index 14ac9d6..60f2f63 100644 (file)
@@ -1617,6 +1617,10 @@ GC_INNER void GC_get_next_stack(char *start, char *limit,
         plast_stack_min = (ptr_t * /* no volatile */)
                             &dll_thread_table[i].last_stack_min;
         current_min = s;
+#       if defined(CPPCHECK)
+          /* To avoid a warning that thread is always null.     */
+          thread = (GC_thread)&dll_thread_table[i];
+#       endif
       }
     }
   } else {