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/ct.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'src/expr/ct.c') diff --git a/src/expr/ct.c b/src/expr/ct.c index 1a21c95..f4a7dc6 100644 --- a/src/expr/ct.c +++ b/src/expr/ct.c @@ -223,8 +223,8 @@ static inline int str2ctdir(const char *str, uint8_t *ctdir) } static int -nftnl_expr_ct_snprintf_default(char *buf, size_t size, - const struct nftnl_expr *e) +nftnl_expr_ct_snprintf(char *buf, size_t size, + uint32_t flags, const struct nftnl_expr *e) { int ret, remain = size, offset = 0; struct nftnl_expr_ct *ct = nftnl_expr_data(e); @@ -250,21 +250,6 @@ nftnl_expr_ct_snprintf_default(char *buf, size_t size, return offset; } -static int -nftnl_expr_ct_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_ct_snprintf_default(buf, len, e); - case NFTNL_OUTPUT_XML: - case NFTNL_OUTPUT_JSON: - default: - break; - } - return -1; -} - struct expr_ops expr_ops_ct = { .name = "ct", .alloc_len = sizeof(struct nftnl_expr_ct), -- cgit v1.2.3