]> granicus.if.org Git - gc/commitdiff
Eliminate 'scope of var can be reduced' cppcheck warning in pthread_join
authorIvan Maidanski <ivmai@mail.ru>
Tue, 10 Jul 2018 21:15:49 +0000 (00:15 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 11 Jul 2018 08:52:34 +0000 (11:52 +0300)
* win32_threads.c [GC_PTHREADS && GC_WIN32_PTHREADS] (GC_pthread_join):
Declare t local variable in the block where the variable is used.

win32_threads.c

index a9cff3fc91d03c30c5abda38c7dbf4bc9978d4ff..3d2fe13ff3237bb659ba7473143ac165ce626036 100644 (file)
@@ -2531,7 +2531,9 @@ GC_INNER void GC_thr_init(void)
   GC_API int GC_pthread_join(pthread_t pthread_id, void **retval)
   {
     int result;
-    GC_thread t;
+#   ifndef GC_WIN32_PTHREADS
+      GC_thread t;
+#   endif
     DCL_LOCK_STATE;
 
     GC_ASSERT(!GC_win32_dll_threads);
@@ -2554,7 +2556,7 @@ GC_INNER void GC_thr_init(void)
     if (0 == result) {
 #     ifdef GC_WIN32_PTHREADS
         /* pthreads-win32 and winpthreads id are unique (not recycled). */
-        t = GC_lookup_pthread(pthread_id);
+        GC_thread t = GC_lookup_pthread(pthread_id);
         if (NULL == t) ABORT("Thread not registered");
 #     endif