]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: Drop dead code from expr_evaluate_mapping()
authorPhil Sutter <phil@nwl.cc>
Fri, 25 Aug 2023 11:49:31 +0000 (13:49 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 2 Nov 2023 10:56:20 +0000 (11:56 +0100)
commit 41f8628f6fb8340dde21e1295191a2d131c1a8df upstream.

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")
Signed-off-by: Phil Sutter <phil@nwl.cc>
src/evaluate.c

index a9eb2ff4cc328d338148847485762a80fc8776fa..937889a2ba2199e919e90ec6db02cfec52109b4d 100644 (file)
@@ -1913,17 +1913,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;