summaryrefslogtreecommitdiffstats
path: root/src/expr/redir.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2021-03-09 10:40:16 +0100
committerPhil Sutter <phil@nwl.cc>2021-03-15 12:23:11 +0100
commitf4ad4d3879cead150e86c279ac8e4770e4b167b1 (patch)
treeeac8c2276ecdcc598fff2707975909d01b56f900 /src/expr/redir.c
parent636fd0daf4890a785e8b165c5ce2c602e5361fcb (diff)
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 <phil@nwl.cc>
Diffstat (limited to 'src/expr/redir.c')
-rw-r--r--src/expr/redir.c20
1 files changed, 3 insertions, 17 deletions
diff --git a/src/expr/redir.c b/src/expr/redir.c
index c00c2a6..8de4c60 100644
--- a/src/expr/redir.c
+++ b/src/expr/redir.c
@@ -131,8 +131,9 @@ nftnl_expr_redir_parse(struct nftnl_expr *e, struct nlattr *attr)
return 0;
}
-static int nftnl_expr_redir_snprintf_default(char *buf, size_t len,
- const struct nftnl_expr *e)
+static int
+nftnl_expr_redir_snprintf(char *buf, size_t len,
+ uint32_t flags, const struct nftnl_expr *e)
{
int ret, remain = len, offset = 0;
struct nftnl_expr_redir *redir = nftnl_expr_data(e);
@@ -158,21 +159,6 @@ static int nftnl_expr_redir_snprintf_default(char *buf, size_t len,
return offset;
}
-static int
-nftnl_expr_redir_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_redir_snprintf_default(buf, len, e);
- case NFTNL_OUTPUT_XML:
- case NFTNL_OUTPUT_JSON:
- default:
- break;
- }
- return -1;
-}
-
struct expr_ops expr_ops_redir = {
.name = "redir",
.alloc_len = sizeof(struct nftnl_expr_redir),