From 75f57d4a7faa4dea1d6a1c59405392a80f04ed20 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 23 May 2017 09:23:54 +0300 Subject: [PATCH] Workaround 'comparison of identical expressions' false code defects * 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 | 5 ++++- thread_local_alloc.c | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pthread_support.c b/pthread_support.c index ee4c599c..5853de20 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -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 { diff --git a/thread_local_alloc.c b/thread_local_alloc.c index ae1286db..ba8ff0f1 100644 --- a/thread_local_alloc.c +++ b/thread_local_alloc.c @@ -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) { -- 2.40.0