From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: [nft PATCH v3 1/3] expression: Introduce is_symbol_value_expr() macro
Date: Thu, 31 Jul 2025 00:25:34 +0200 [thread overview]
Message-ID: <20250730222536.786-2-phil@nwl.cc> (raw)
In-Reply-To: <20250730222536.786-1-phil@nwl.cc>
Annotate and combine the 'etype' and 'symtype' checks done in bison
parser for readability and because JSON parser will start doing the same
in a follow-up patch.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
include/expression.h | 2 ++
src/parser_bison.y | 6 ++----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/expression.h b/include/expression.h
index 5b60c1b0825e3..e483b7e76f4ca 100644
--- a/include/expression.h
+++ b/include/expression.h
@@ -470,6 +470,8 @@ extern struct expr *verdict_expr_alloc(const struct location *loc,
extern struct expr *symbol_expr_alloc(const struct location *loc,
enum symbol_types type, struct scope *scope,
const char *identifier);
+#define is_symbol_value_expr(expr) \
+ ((expr)->etype == EXPR_SYMBOL && (expr)->symtype == SYMBOL_VALUE)
const char *expr_name(const struct expr *e);
diff --git a/src/parser_bison.y b/src/parser_bison.y
index c31fd05ec09cd..0b03e4dad1a3f 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -4486,10 +4486,8 @@ prefix_rhs_expr : basic_rhs_expr SLASH NUM
range_rhs_expr : basic_rhs_expr DASH basic_rhs_expr
{
- if ($1->etype == EXPR_SYMBOL &&
- $1->symtype == SYMBOL_VALUE &&
- $3->etype == EXPR_SYMBOL &&
- $3->symtype == SYMBOL_VALUE) {
+ if (is_symbol_value_expr($1) &&
+ is_symbol_value_expr($3)) {
$$ = symbol_range_expr_alloc(&@$, $1->symtype, $1->scope, $1->identifier, $3->identifier);
expr_free($1);
expr_free($3);
--
2.49.0
next prev parent reply other threads:[~2025-07-30 22:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-30 22:25 [nft PATCH v3 0/3] evaluate: Fix for 'meta hour' ranges spanning date boundaries Phil Sutter
2025-07-30 22:25 ` Phil Sutter [this message]
2025-07-30 22:25 ` [nft PATCH v3 2/3] parser_json: Parse into symbol range expression if possible Phil Sutter
2025-07-30 22:25 ` [nft PATCH v3 3/3] evaluate: Fix for 'meta hour' ranges spanning date boundaries Phil Sutter
2025-07-31 11:19 ` [nft PATCH v3 0/3] " Pablo Neira Ayuso
2025-07-31 13:01 ` Phil Sutter
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=20250730222536.786-2-phil@nwl.cc \
--to=phil@nwl.cc \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.