]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
expression: Introduce is_symbol_value_expr() macro
authorPhil Sutter <phil@nwl.cc>
Tue, 29 Jul 2025 15:52:35 +0000 (17:52 +0200)
committerPhil Sutter <phil@nwl.cc>
Thu, 31 Jul 2025 11:26:51 +0000 (13:26 +0200)
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>
Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/expression.h
src/parser_bison.y

index 5b60c1b0825e3322f0894bd0a5de6c3ea4717a14..e483b7e76f4cae3f18c6797155cb3d0668dd197d 100644 (file)
@@ -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);
 
index aacfa2917917376de037361c3545e5fe18048a51..0b1ea699c6102023f925a8d3ae9b512ec67ed0dd 100644 (file)
@@ -4496,10 +4496,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);