[前][次][番号順一覧][スレッド一覧]

ruby-changes:55898

From: Kazuhiro <ko1@a...>
Date: Wed, 29 May 2019 13:16:39 +0900 (JST)
Subject: [ruby-changes:55898] Kazuhiro NISHIYAMA: aee36bf149 (trunk): Fix Possible Control flow issues (DEADCODE)

https://git.ruby-lang.org/ruby.git/commit/?id=aee36bf149

From aee36bf149bedf97007584ac5d6cd5d438be28b5 Mon Sep 17 00:00:00 2001
From: Kazuhiro NISHIYAMA <zn@m...>
Date: Wed, 29 May 2019 13:12:15 +0900
Subject: Fix Possible Control flow issues (DEADCODE)

Coverity Scan says `Execution cannot reach this statement: "poison_object(v);"`,
so do nothing when `ptr` is always 0 without address_sanitizer.

diff --git a/internal.h b/internal.h
index e986098..fcaffa2 100644
--- a/internal.h
+++ b/internal.h
@@ -155,6 +155,14 @@ asan_poison_object(VALUE obj) https://github.com/ruby/ruby/blob/trunk/internal.h#L155
     asan_poison_memory_region(ptr, SIZEOF_VALUE);
 }
 
+#if !__has_feature(address_sanitizer)
+#define asan_poison_object_if(ptr, obj) ((void)(ptr), (void)(obj))
+#else
+#define asan_poison_object_if(ptr, obj) do { \
+        if (ptr) asan_poison_object(obj); \
+    } while (0)
+#endif
+
 /*!
  * This function predicates if the given object is fully addressable or not.
  *
diff --git a/iseq.c b/iseq.c
index b8895a5..916715e 100644
--- a/iseq.c
+++ b/iseq.c
@@ -1087,9 +1087,7 @@ remove_coverage_i(void *vstart, void *vend, size_t stride, void *data) https://github.com/ruby/ruby/blob/trunk/iseq.c#L1087
             ISEQ_COVERAGE_SET(iseq, Qnil);
 	}
 
-        if (ptr) {
-            asan_poison_object(v);
-        }
+        asan_poison_object_if(ptr, v);
     }
     return 0;
 }
@@ -3239,9 +3237,7 @@ trace_set_i(void *vstart, void *vend, size_t stride, void *data) https://github.com/ruby/ruby/blob/trunk/iseq.c#L3237
 	    rb_iseq_trace_set(rb_iseq_check((rb_iseq_t *)v), turnon_events);
 	}
 
-        if (ptr) {
-            asan_poison_object(v);
-        }
+        asan_poison_object_if(ptr, v);
     }
     return 0;
 }
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]