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/byteorder.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'src/expr/byteorder.c') diff --git a/src/expr/byteorder.c b/src/expr/byteorder.c index efdfa2b..9718b8f 100644 --- a/src/expr/byteorder.c +++ b/src/expr/byteorder.c @@ -197,8 +197,9 @@ static inline int nftnl_str2ntoh(const char *op) } } -static int nftnl_expr_byteorder_snprintf_default(char *buf, size_t size, - const struct nftnl_expr *e) +static int +nftnl_expr_byteorder_snprintf(char *buf, size_t size, + uint32_t flags, const struct nftnl_expr *e) { struct nftnl_expr_byteorder *byteorder = nftnl_expr_data(e); int remain = size, offset = 0, ret; @@ -211,21 +212,6 @@ static int nftnl_expr_byteorder_snprintf_default(char *buf, size_t size, return offset; } -static int -nftnl_expr_byteorder_snprintf(char *buf, size_t size, uint32_t type, - uint32_t flags, const struct nftnl_expr *e) -{ - switch (type) { - case NFTNL_OUTPUT_DEFAULT: - return nftnl_expr_byteorder_snprintf_default(buf, size, e); - case NFTNL_OUTPUT_XML: - case NFTNL_OUTPUT_JSON: - default: - break; - } - return -1; -} - struct expr_ops expr_ops_byteorder = { .name = "byteorder", .alloc_len = sizeof(struct nftnl_expr_byteorder), -- cgit v1.2.3