[nft,2/4] segtree: Drop dead code in ei_insert()
diff mbox series

Message ID 20200123143049.13888-3-phil@nwl.cc
State Changes Requested
Delegated to: Pablo Neira
Headers show
Series
  • Covscan-induced review of ei_insert()
Related show

Commit Message

Phil Sutter Jan. 23, 2020, 2:30 p.m. UTC
Caller sorts new items to be added, therefore when checking for overlaps
the current range can only overlap on lower end. Drop the check for
upper end overlap.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 src/segtree.c | 20 --------------------
 1 file changed, 20 deletions(-)

Comments

Pablo Neira Ayuso Jan. 28, 2020, 11:24 a.m. UTC | #1
On Thu, Jan 23, 2020 at 03:30:47PM +0100, Phil Sutter wrote:
> Caller sorts new items to be added, therefore when checking for overlaps
> the current range can only overlap on lower end. Drop the check for
> upper end overlap.
> 
> Signed-off-by: Phil Sutter <phil@nwl.cc>

Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>

The iteration over the sorted array guarantees there cannot be an
interval.

Patch
diff mbox series

diff --git a/src/segtree.c b/src/segtree.c
index aa1f1c38d789c..47e326533ac39 100644
--- a/src/segtree.c
+++ b/src/segtree.c
@@ -228,26 +228,6 @@  static int ei_insert(struct list_head *msgs, struct seg_tree *tree,
 				ei_destroy(lei);
 			}
 		}
-		if (rei != NULL) {
-			if (!merge)
-				goto err;
-			/*
-			 * Right endpoint is within rei, adjust it so we have:
-			 *
-			 * [new_left, new_right](new_right, rei_right]
-			 */
-			if (segtree_debug(tree->debug_mask)) {
-				pr_gmp_debug("adjust right [%Zx %Zx]\n",
-					     rei->left, rei->right);
-			}
-
-			mpz_add_ui(rei->left, new->right, 1);
-			mpz_sub(rei->size, rei->right, rei->left);
-			if (mpz_sgn(rei->size) < 0) {
-				ei_remove(tree, rei);
-				ei_destroy(rei);
-			}
-		}
 	}
 
 	__ei_insert(tree, new);