From f4ad4d3879cead150e86c279ac8e4770e4b167b1 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 9 Mar 2021 10:40:16 +0100 Subject: expr: Check output type once and for all There is but a single supported output type left, so check it in expr.c and drop all the single option switch statements in individual expressions. Since the parameter is now unused (and to ensure code correctness), drop 'type' parameter from struct expr_ops' snprintf callback. Signed-off-by: Phil Sutter --- src/expr/dup.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'src/expr/dup.c') diff --git a/src/expr/dup.c b/src/expr/dup.c index 7a3ee96..3eb560a 100644 --- a/src/expr/dup.c +++ b/src/expr/dup.c @@ -111,9 +111,8 @@ static int nftnl_expr_dup_parse(struct nftnl_expr *e, struct nlattr *attr) return ret; } -static int nftnl_expr_dup_snprintf_default(char *buf, size_t len, - const struct nftnl_expr *e, - uint32_t flags) +static int nftnl_expr_dup_snprintf(char *buf, size_t len, + uint32_t flags, const struct nftnl_expr *e) { int remain = len, offset = 0, ret; struct nftnl_expr_dup *dup = nftnl_expr_data(e); @@ -131,20 +130,6 @@ static int nftnl_expr_dup_snprintf_default(char *buf, size_t len, return offset; } -static int nftnl_expr_dup_snprintf(char *buf, size_t len, uint32_t type, - uint32_t flags, const struct nftnl_expr *e) -{ - switch (type) { - case NFTNL_OUTPUT_DEFAULT: - return nftnl_expr_dup_snprintf_default(buf, len, e, flags); - case NFTNL_OUTPUT_XML: - case NFTNL_OUTPUT_JSON: - default: - break; - } - return -1; -} - struct expr_ops expr_ops_dup = { .name = "dup", .alloc_len = sizeof(struct nftnl_expr_dup), -- cgit v1.2.3