Skip to contentSkip to conversation

segtree: keep element comments in set intervals

PATCH In review Pablo Neira Ayuso 2 participants 2 messages Nov 8, 2016 – Nov 9, 2016 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 segtree: keep element comments in set intervals

The conversion from the set element range representation to element intervals doesn't keep the comment information around.

---
 src/segtree.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
src/segtree.c +7 -3
index fa11967adbd2..32e071f6b5e8 100644
@@ -522,9 +522,13 @@ static void set_insert_interval(struct expr *set, struct seg_tree *tree,
 	mpz_set(expr->value, ei->left);
 	expr = set_elem_expr_alloc(&internal_location, expr);
 
-	if (ei->expr != NULL && ei->expr->ops->type == EXPR_MAPPING)
-		expr = mapping_expr_alloc(&ei->expr->location, expr,
-					  expr_get(ei->expr->right));
+	if (ei->expr != NULL) {
+		if (ei->expr->comment)
+			expr->comment = xstrdup(ei->expr->comment);
+		if (ei->expr->ops->type == EXPR_MAPPING)
+			expr = mapping_expr_alloc(&ei->expr->location, expr,
+						  expr_get(ei->expr->right));
+	}
 
 	if (ei->flags & EI_F_INTERVAL_END)
 		expr->flags |= EXPR_F_INTERVAL_END;
Signature · 1 line
2.1.4
Tested-by on v1 1/1
#1 lore raw
Quoted 9 lines · Pablo Neira Ayuso

The conversion from the set element range representation to element intervals doesn't keep the comment information around.

---
 src/segtree.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Hi,

just tested this patch before/after, and it really works.

I think we can add some testcase to catch possible regressions. Will send a patch.