Message ID | 20200123143049.13888-4-phil@nwl.cc |
---|---|
State | Changes Requested |
Delegated to: | Pablo Neira |
Headers | show |
Series | Covscan-induced review of ei_insert() | expand |
On Thu, Jan 23, 2020 at 03:30:48PM +0100, Phil Sutter wrote: > Since upper boundary overlaps can't happen, lower boundary overlaps may > simply be resolved by adjusting the existing range's upper boundary to > that of the new one instead of adding elements which are later dropped > again. I would append to this description that this only happens if auto-merge is set on. > Signed-off-by: Phil Sutter <phil@nwl.cc> Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
diff --git a/src/segtree.c b/src/segtree.c index 47e326533ac39..3c0989e76093a 100644 --- a/src/segtree.c +++ b/src/segtree.c @@ -214,19 +214,16 @@ static int ei_insert(struct list_head *msgs, struct seg_tree *tree, /* * Left endpoint is within lei, adjust it so we have: * - * [lei_left, new_left)[new_left, new_right] + * [lei_left, new_right] */ if (segtree_debug(tree->debug_mask)) { pr_gmp_debug("adjust left [%Zx %Zx]\n", lei->left, lei->right); } - mpz_sub_ui(lei->right, new->left, 1); - mpz_sub(lei->size, lei->right, lei->left); - if (mpz_sgn(lei->size) < 0) { - ei_remove(tree, lei); - ei_destroy(lei); - } + mpz_set(lei->right, new->right); + ei_destroy(new); + return 0; } }
Since upper boundary overlaps can't happen, lower boundary overlaps may simply be resolved by adjusting the existing range's upper boundary to that of the new one instead of adding elements which are later dropped again. Signed-off-by: Phil Sutter <phil@nwl.cc> --- src/segtree.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)