netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [nft PATCH] evaluate: Drop dead code from expr_evaluate_mapping()
@ 2023-08-25 11:55 Phil Sutter
  0 siblings, 0 replies; 3+ messages in thread
From: Phil Sutter @ 2023-08-25 11:55 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netfilter-devel

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 | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/evaluate.c b/src/evaluate.c
index 2b158aee720bd..5d22a04294ca7 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [nft PATCH] evaluate: Drop dead code from expr_evaluate_mapping()
@ 2023-08-29 13:54 Phil Sutter
  2023-08-29 16:10 ` Phil Sutter
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Sutter @ 2023-08-29 13:54 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

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 | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/evaluate.c b/src/evaluate.c
index 2b158aee720bd..5d22a04294ca7 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -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;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [nft PATCH] evaluate: Drop dead code from expr_evaluate_mapping()
  2023-08-29 13:54 [nft PATCH] evaluate: Drop dead code from expr_evaluate_mapping() Phil Sutter
@ 2023-08-29 16:10 ` Phil Sutter
  0 siblings, 0 replies; 3+ messages in thread
From: Phil Sutter @ 2023-08-29 16:10 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

On Tue, Aug 29, 2023 at 03:54:24PM +0200, Phil Sutter wrote:
> 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>

Patch applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-29 16:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-29 13:54 [nft PATCH] evaluate: Drop dead code from expr_evaluate_mapping() Phil Sutter
2023-08-29 16:10 ` Phil Sutter
  -- strict thread matches above, loose matches on Subject: below --
2023-08-25 11:55 Phil Sutter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).