[nft PATCH 3/4] expression: Introduce compound_expr_last

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

 



This function retrieves the last element in a compound expression.

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 include/expression.h | 1 +
 src/expression.c     | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/include/expression.h b/include/expression.h
index 68a36e8af792a..13ff5e981bed7 100644
--- a/include/expression.h
+++ b/include/expression.h
@@ -403,6 +403,7 @@ extern struct expr *range_expr_alloc(const struct location *loc,
 
 extern void compound_expr_add(struct expr *compound, struct expr *expr);
 extern void compound_expr_remove(struct expr *compound, struct expr *expr);
+extern struct expr *compound_expr_last(struct expr *compound);
 extern void list_expr_sort(struct list_head *head);
 
 extern struct expr *concat_expr_alloc(const struct location *loc);
diff --git a/src/expression.c b/src/expression.c
index d41ada39cc0ff..ac1373a7f11b6 100644
--- a/src/expression.c
+++ b/src/expression.c
@@ -700,6 +700,13 @@ void compound_expr_remove(struct expr *compound, struct expr *expr)
 	list_del(&expr->list);
 }
 
+struct expr *compound_expr_last(struct expr *compound)
+{
+	if (!compound->size)
+		return NULL;
+	return list_last_entry(&compound->expressions, struct expr, list);
+}
+
 static void concat_expr_destroy(struct expr *expr)
 {
 	concat_type_destroy(expr->dtype);
-- 
2.13.1

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux