This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 0ee898d  Clang Analyzer: Fix IpMap.cc false positives.
0ee898d is described below

commit 0ee898d63e65ee8ccafc3bd55b85b2f25aa4ef2d
Author: Alan M. Carroll <[email protected]>
AuthorDate: Thu Apr 25 04:50:25 2019 -0500

    Clang Analyzer: Fix IpMap.cc false positives.
---
 src/tscore/IpMap.cc | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/tscore/IpMap.cc b/src/tscore/IpMap.cc
index 2fd01f8..89f1143 100644
--- a/src/tscore/IpMap.cc
+++ b/src/tscore/IpMap.cc
@@ -382,8 +382,11 @@ namespace detail
       if (n->_data == payload) {
         if (x) {
           if (n->_max <= max) {
-            // next range is covered, so we can remove and continue.
-            this->remove(n);
+// next range is covered, so we can remove and continue.
+#if defined(__clang_analyzer__)
+            ink_assert(x != n)
+#endif
+              this->remove(n);
             n = next(x);
           } else if (n->_min <= max_plus1) {
             // Overlap or adjacent with larger max - absorb and finish.
@@ -642,10 +645,14 @@ namespace detail
   void
   IpMapBase<N>::insert_before(N *spot, N *n)
   {
-    N *c = left(spot);
-    if (!c) {
+    if (left(spot) == nullptr) {
       spot->setChild(n, N::LEFT);
     } else {
+// If there's a left child, there's a previous node, therefore spot->_prev is 
valid.
+// Clang analyzer doesn't realize this so it generates a false positive.
+#if defined(__clang_analyzer__)
+      ink_assert(spot->_prev != nullptr);
+#endif
       spot->_prev->setChild(n, N::RIGHT);
     }
 

Reply via email to