From: Ivan Maidanski Date: Wed, 28 Sep 2016 07:04:39 +0000 (+0300) Subject: Eliminate 'comparison is always false' static analyzer warning in finalize X-Git-Tag: v8.0.0~1136 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6783d150effd76f4e77111672ba6ba2c74e024d1;p=gc Eliminate 'comparison is always false' static analyzer warning in finalize GC_enqueue_all_finalizers code refactoring is done (removal of the unreachable statement) to eliminate the warning. * finalize.c (GC_enqueue_all_finalizers): Remove "prev_fo" local variable; remove "register" keyword for local variables; remove the pointer to the chain of hash table entries from the roots (i.e. setting the roots pointer to null) at the beginning of processing the chain (instead of updating the roots pointer on deletion of each entry and finally setting it to null); remove fo_set_next(prev_fo) as it is never called (because prev_fo was always null); update GC_fo_entries only when the whole table processed (i.e. all items removed). --- diff --git a/finalize.c b/finalize.c index 514e42d9..1b570c2c 100644 --- a/finalize.c +++ b/finalize.c @@ -1088,29 +1088,22 @@ GC_INNER void GC_finalize(void) /* Enqueue all remaining finalizers to be run - Assumes lock is held. */ STATIC void GC_enqueue_all_finalizers(void) { - struct finalizable_object * curr_fo, * prev_fo, * next_fo; + struct finalizable_object * curr_fo, * next_fo; ptr_t real_ptr; - register int i; + int i; int fo_size; fo_size = log_fo_table_size == -1 ? 0 : 1 << log_fo_table_size; GC_bytes_finalized = 0; for (i = 0; i < fo_size; i++) { curr_fo = GC_fnlz_roots.fo_head[i]; - prev_fo = NULL; + GC_fnlz_roots.fo_head[i] = NULL; while (curr_fo != NULL) { real_ptr = GC_REVEAL_POINTER(curr_fo -> fo_hidden_base); GC_MARK_FO(real_ptr, GC_normal_finalize_mark_proc); GC_set_mark_bit(real_ptr); - /* Delete from hash table */ next_fo = fo_next(curr_fo); - if (prev_fo == 0) { - GC_fnlz_roots.fo_head[i] = next_fo; - } else { - fo_set_next(prev_fo, next_fo); - } - GC_fo_entries--; /* Add to list of objects awaiting finalization. */ fo_set_next(curr_fo, GC_fnlz_roots.finalize_now); @@ -1125,6 +1118,7 @@ GC_INNER void GC_finalize(void) curr_fo = next_fo; } } + GC_fo_entries = 0; /* all entries deleted from the hash table */ } /* Invoke all remaining finalizers that haven't yet been run.