]> granicus.if.org Git - gc/commitdiff
Workaround 'comparison of identical expressions' false code defects
authorIvan Maidanski <ivmai@mail.ru>
Tue, 23 May 2017 06:23:54 +0000 (09:23 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 23 May 2017 22:32:04 +0000 (01:32 +0300)
* thread_local_alloc.c [THREAD_LOCAL_ALLOC] (GC_init_thread_local):
New local variable (res); save result of GC_setspecific and
GC_key_create to res; replace res!=0 with COVERT_DATAFLOW(res)!=0.
* pthread_support.c [CAN_HANDLE_FORK] (GC_remove_all_threads_but_me):
Likewise.

pthread_support.c
thread_local_alloc.c

index ee4c599c73a80ee768939969efd81bf787763eda..5853de205d4f8ae37be88a0a75f584a445d4c71e 100644 (file)
@@ -728,6 +728,8 @@ STATIC void GC_remove_all_threads_but_me(void)
       for (p = GC_threads[hv]; 0 != p; p = next) {
         next = p -> next;
         if (THREAD_EQUAL(p -> id, self)) {
+          int res;
+
           me = p;
           p -> next = 0;
 #         ifdef GC_DARWIN_THREADS
@@ -744,7 +746,8 @@ STATIC void GC_remove_all_threads_but_me(void)
             /* we re-assign thread-local pointer to 'tlfs' for safety   */
             /* instead of the assertion check (again, it is OK to call  */
             /* GC_destroy_thread_local and GC_free_internal before).    */
-            if (GC_setspecific(GC_thread_key, &me->tlfs) != 0)
+            res = GC_setspecific(GC_thread_key, &me->tlfs);
+            if (COVERT_DATAFLOW(res) != 0)
               ABORT("GC_setspecific failed (in child)");
 #         endif
         } else {
index ae1286db1ac51fcd5fb9cbecf99a831c5e928630..ba8ff0f12ed902d91048e7f07d3e2cc184535344 100644 (file)
@@ -93,17 +93,19 @@ static void return_freelists(void **fl, void **gfl)
 /* This call must be made from the new thread.  */
 GC_INNER void GC_init_thread_local(GC_tlfs p)
 {
-    int i, j;
+    int i, j, res;
 
     GC_ASSERT(I_HOLD_LOCK());
     if (!EXPECT(keys_initialized, TRUE)) {
         GC_ASSERT((word)&GC_thread_key % sizeof(word) == 0);
-        if (0 != GC_key_create(&GC_thread_key, reset_thread_key)) {
+        res = GC_key_create(&GC_thread_key, reset_thread_key);
+        if (COVERT_DATAFLOW(res) != 0) {
             ABORT("Failed to create key for local allocator");
         }
         keys_initialized = TRUE;
     }
-    if (0 != GC_setspecific(GC_thread_key, p)) {
+    res = GC_setspecific(GC_thread_key, p);
+    if (COVERT_DATAFLOW(res) != 0) {
         ABORT("Failed to set thread specific allocation pointers");
     }
     for (j = 0; j < TINY_FREELISTS; ++j) {