[nft PATCH v3 1/3] expression: Introduce is_symbol_value_expr() macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---
 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





[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux