Skip to contentSkip to conversation

evaluate: Drop dead code from expr_evaluate_mapping()

PATCH In review Phil Sutter 1 participant 2 messages Aug 29, 2023 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 evaluate: Drop dead code from expr_evaluate_mapping()

Since commit 343a51702656a ("src: store expr, not dtype to track data in sets"), set->data is allocated for object maps in set_evaluate(), all other map types have set->data initialized by the parser already, set_evaluate() also checks that.

Drop the confusing check, later in the function set->data is dereferenced unconditionally.

Fixes 343a51702656a ("src: store expr, not dtype to track data in sets")
---
 src/evaluate.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
src/evaluate.c +8 -11
index 2b158aee720bd..5d22a04294ca7 100644
@@ -2061,17 +2061,14 @@ static int expr_evaluate_mapping(struct eval_ctx *ctx, struct expr **expr)
 				  "Key must be a constant");
 	mapping->flags |= mapping->left->flags & EXPR_F_SINGLETON;
 
-	if (set->data) {
-		if (!set_is_anonymous(set->flags) &&
-		    set->data->flags & EXPR_F_INTERVAL)
-			datalen = set->data->len / 2;
-		else
-			datalen = set->data->len;
-
-		__expr_set_context(&ctx->ectx, set->data->dtype, set->data->byteorder, datalen, 0);
-	} else {
-		assert((set->flags & NFT_SET_MAP) == 0);
-	}
+	assert(set->data != NULL);
+	if (!set_is_anonymous(set->flags) &&
+	    set->data->flags & EXPR_F_INTERVAL)
+		datalen = set->data->len / 2;
+	else
+		datalen = set->data->len;
+	__expr_set_context(&ctx->ectx, set->data->dtype,
+			   set->data->byteorder, datalen, 0);
 
 	if (expr_evaluate(ctx, &mapping->right) < 0)
 		return -1;
Signature · 1 line
2.41.0
author reviewer
#1 lore raw
Quoted 10 lines · Phil Sutter

Since commit 343a51702656a ("src: store expr, not dtype to track data in sets"), set->data is allocated for object maps in set_evaluate(), all other map types have set->data initialized by the parser already, set_evaluate() also checks that.

Drop the confusing check, later in the function set->data is dereferenced unconditionally.

Fixes 343a51702656a ("src: store expr, not dtype to track data in sets")

Patch applied.