From: Ivan Maidanski Date: Tue, 23 Apr 2019 19:21:54 +0000 (+0300) Subject: Workaround 'duplicate expression for condition and assignment' cppcheck FP X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fa8b492e30a8161416c9362843c21d049735b848;p=gc Workaround 'duplicate expression for condition and assignment' cppcheck FP The entitled cppcheck warnings are false positives. * alloc.c (GC_should_collect): Move reassignment of the global variable which is checked in the conditional expression to the end of the conditional block statement. * finalize.c (GC_notify_or_invoke_finalizers): Likewise. * mark.c [WRAP_MARK_SOME] (GC_mark_some): Likewise. --- diff --git a/alloc.c b/alloc.c index a0c2a1c3..45fd0869 100644 --- a/alloc.c +++ b/alloc.c @@ -388,8 +388,8 @@ GC_INNER GC_bool GC_should_collect(void) static word last_min_bytes_allocd; static word last_gc_no; if (last_gc_no != GC_gc_no) { - last_gc_no = GC_gc_no; last_min_bytes_allocd = min_bytes_allocd(); + last_gc_no = GC_gc_no; } return(GC_adj_bytes_allocd() >= last_min_bytes_allocd || GC_heapsize >= GC_collect_at_heapsize); diff --git a/finalize.c b/finalize.c index d01c2aa8..5c23b4c4 100644 --- a/finalize.c +++ b/finalize.c @@ -1368,8 +1368,8 @@ GC_INNER void GC_notify_or_invoke_finalizers(void) /* These variables require synchronization to avoid data races. */ if (last_finalizer_notification != GC_gc_no) { - last_finalizer_notification = GC_gc_no; notifier_fn = GC_finalizer_notifier; + last_finalizer_notification = GC_gc_no; } UNLOCK(); if (notifier_fn != 0) diff --git a/mark.c b/mark.c index 77e9dbb1..6aed170e 100644 --- a/mark.c +++ b/mark.c @@ -564,9 +564,9 @@ handle_ex: /* Warn about it at most once per collection. */ if (warned_gc_no != GC_gc_no) { - warned_gc_no = GC_gc_no; WARN("Caught ACCESS_VIOLATION in marker;" " memory mapping disappeared\n", 0); + warned_gc_no = GC_gc_no; } } /* We have bad roots on the stack. Discard mark stack. */