From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft,v2 10/11] expression: replace compound_expr_print() by type safe function
Date: Thu, 21 Aug 2025 11:23:29 +0200 [thread overview]
Message-ID: <20250821092330.2739989-11-pablo@netfilter.org> (raw)
In-Reply-To: <20250821092330.2739989-1-pablo@netfilter.org>
Replace compound_expr_print() by {list,set,concat}_expr_print() to
validate expression type.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/expression.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/src/expression.c b/src/expression.c
index 8d604fba265e..c0ab5d5598f2 100644
--- a/src/expression.c
+++ b/src/expression.c
@@ -1027,19 +1027,6 @@ struct expr *compound_expr_alloc(const struct location *loc,
return expr;
}
-static void compound_expr_print(const struct expr *expr, const char *delim,
- struct output_ctx *octx)
-{
- const struct expr *i;
- const char *d = "";
-
- list_for_each_entry(i, &expr->expr_set.expressions, list) {
- nft_print(octx, "%s", d);
- expr_print(i, octx);
- d = delim;
- }
-}
-
static void concat_expr_destroy(struct expr *expr)
{
struct expr *i, *next;
@@ -1050,7 +1037,14 @@ static void concat_expr_destroy(struct expr *expr)
static void concat_expr_print(const struct expr *expr, struct output_ctx *octx)
{
- compound_expr_print(expr, " . ", octx);
+ const struct expr *i;
+ const char *d = "";
+
+ list_for_each_entry(i, &expr_concat(expr)->expressions, list) {
+ nft_print(octx, "%s", d);
+ expr_print(i, octx);
+ d = " . ";
+ }
}
static void concat_expr_clone(struct expr *new, const struct expr *expr)
@@ -1244,7 +1238,14 @@ void concat_expr_remove(struct expr *concat, struct expr *expr)
static void list_expr_print(const struct expr *expr, struct output_ctx *octx)
{
- compound_expr_print(expr, ",", octx);
+ const struct expr *i;
+ const char *d = "";
+
+ list_for_each_entry(i, &expr_list(expr)->expressions, list) {
+ nft_print(octx, "%s", d);
+ expr_print(i, octx);
+ d = ",";
+ }
}
static void list_expr_clone(struct expr *new, const struct expr *expr)
--
2.30.2
next prev parent reply other threads:[~2025-08-21 9:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-21 9:23 [PATCH nft,v2 00/11] replace compound_expr_*() by type safe function Pablo Neira Ayuso
2025-08-21 9:23 ` [PATCH nft,v2 01/11] src: add expr_type_catchall() helper and use it Pablo Neira Ayuso
2025-08-21 9:23 ` [PATCH nft,v2 02/11] src: replace compound_expr_add() by type safe set_expr_add() Pablo Neira Ayuso
2025-08-21 9:23 ` [PATCH nft,v2 03/11] src: replace compound_expr_add() by type safe concat_expr_add() Pablo Neira Ayuso
2025-08-21 9:23 ` [PATCH nft,v2 04/11] src: replace compound_expr_add() by type safe list_expr_add() Pablo Neira Ayuso
2025-08-21 9:23 ` [PATCH nft,v2 05/11] segtree: rename set_compound_expr_add() to set_expr_add_splice() Pablo Neira Ayuso
2025-08-21 9:23 ` [PATCH nft,v2 06/11] expression: replace compound_expr_clone() by type safe function Pablo Neira Ayuso
2025-08-21 9:23 ` [PATCH nft,v2 07/11] expression: remove compound_expr_add() Pablo Neira Ayuso
2025-08-21 9:23 ` [PATCH nft,v2 08/11] expression: replace compound_expr_remove() by type safe function Pablo Neira Ayuso
2025-08-21 9:23 ` [PATCH nft,v2 09/11] expression: replace compound_expr_destroy() by type safe funtion Pablo Neira Ayuso
2025-08-21 9:23 ` Pablo Neira Ayuso [this message]
2025-08-21 9:23 ` [PATCH nft,v2 11/11] src: replace compound_expr_alloc() by type safe function Pablo Neira Ayuso
2025-08-27 22:24 ` [PATCH nft,v2 00/11] replace compound_expr_*() " Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250821092330.2739989-11-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).