]> granicus.if.org Git - gc/commitdiff
Reduce scope of local variables in GC_remove_all_threads_but_me
authorIvan Maidanski <ivmai@mail.ru>
Thu, 8 Nov 2018 21:45:14 +0000 (00:45 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 26 Nov 2018 06:06:54 +0000 (09:06 +0300)
This eliminates 'the scope of the variable can be reduced' cppcheck
warning in GC_remove_all_threads_but_me.

* pthread_support.c [CAN_HANDLE_FORK] (GC_remove_all_threads_but_me):
Move p, next, me local variables to an inner scope there they are used.
* win32_threads.c [CAN_HANDLE_FORK] (GC_remove_all_threads_but_me):
Move p, next local variables to an inner scope.

pthread_support.c
win32_threads.c

index e6622e020a7f7ac86731b86f2d4f882b55883d6b..abcb3dc14d52b64db433bee98bd9d23b8f7b493b 100644 (file)
@@ -762,10 +762,11 @@ STATIC void GC_remove_all_threads_but_me(void)
 {
     pthread_t self = pthread_self();
     int hv;
-    GC_thread p, next, me;
 
     for (hv = 0; hv < THREAD_TABLE_SZ; ++hv) {
-      me = 0;
+      GC_thread p, next;
+      GC_thread me = NULL;
+
       for (p = GC_threads[hv]; 0 != p; p = next) {
         next = p -> next;
         if (THREAD_EQUAL(p -> id, self)
index 367d9f3c9921e3a7a3a17ea23f67f14f5271fc78..575724e0fc33b18587a1d02ed336e12880f43f8c 100644 (file)
@@ -1033,12 +1033,14 @@ GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
     STATIC void GC_remove_all_threads_but_me(void)
     {
       int hv;
-      GC_thread p, next, me = NULL;
+      GC_thread me = NULL;
       DWORD thread_id;
       pthread_t pthread_id = pthread_self(); /* same as in parent */
 
       GC_ASSERT(!GC_win32_dll_threads);
       for (hv = 0; hv < THREAD_TABLE_SZ; ++hv) {
+        GC_thread p, next;
+
         for (p = GC_threads[hv]; 0 != p; p = next) {
           next = p -> tm.next;
           if (THREAD_EQUAL(p -> pthread_id, pthread_id)