]> granicus.if.org Git - gc/commitdiff
Workaround 'redundant initialization for r' cppcheck false positive
authorIvan Maidanski <ivmai@mail.ru>
Tue, 10 Sep 2019 20:35:14 +0000 (23:35 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 10 Sep 2019 20:35:43 +0000 (23:35 +0300)
* mark.c (GC_mark_and_push_stack): Replace "if(a&&b)" with
"if(a) if(b)" where b is an expression which contains r variable
assignment.

mark.c

diff --git a/mark.c b/mark.c
index 4d702a9333dd0858461bd57bd4fd2f4f850113b0..0a1d13941c38296b5a01a0aa88851b085721fe7a 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -1483,12 +1483,13 @@ GC_API struct GC_ms_entry * GC_CALL GC_mark_and_push(void *obj,
 
     PREFETCH(p);
     GET_HDR(p, hhdr);
-    if (EXPECT(IS_FORWARDING_ADDR_OR_NIL(hhdr), FALSE)
-        && (NULL == hhdr
+    if (EXPECT(IS_FORWARDING_ADDR_OR_NIL(hhdr), FALSE)) {
+      if (NULL == hhdr
             || (r = (ptr_t)GC_base(p)) == NULL
-            || (hhdr = HDR(r)) == NULL)) {
+            || (hhdr = HDR(r)) == NULL) {
         GC_ADD_TO_BLACK_LIST_STACK(p, source);
         return;
+      }
     }
     if (EXPECT(HBLK_IS_FREE(hhdr), FALSE)) {
         GC_ADD_TO_BLACK_LIST_NORMAL(p, source);