From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: [libnftnl PATCH 06/10] expr/data_reg: Drop output_format parameter
Date: Tue, 9 Mar 2021 16:45:12 +0100 [thread overview]
Message-ID: <20210309154516.4987-7-phil@nwl.cc> (raw)
In-Reply-To: <20210309154516.4987-1-phil@nwl.cc>
The function nftnl_data_reg_snprintf is exclusively called with
NFTNL_OUTPUT_DEFAULT as parameter, others are not supported - just drop
it.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
include/data_reg.h | 3 +--
src/expr/bitwise.c | 6 +++---
src/expr/cmp.c | 2 +-
src/expr/data_reg.c | 31 ++++++-------------------------
src/expr/immediate.c | 6 +++---
src/expr/range.c | 4 ++--
src/set_elem.c | 3 ---
7 files changed, 16 insertions(+), 39 deletions(-)
diff --git a/include/data_reg.h b/include/data_reg.h
index 0d6b77829cf89..6d2dc66858bf8 100644
--- a/include/data_reg.h
+++ b/include/data_reg.h
@@ -31,8 +31,7 @@ union nftnl_data_reg {
int nftnl_data_reg_snprintf(char *buf, size_t size,
const union nftnl_data_reg *reg,
- uint32_t output_format, uint32_t flags,
- int reg_type);
+ uint32_t flags, int reg_type);
struct nlattr;
int nftnl_parse_data(union nftnl_data_reg *data, struct nlattr *attr, int *type);
diff --git a/src/expr/bitwise.c b/src/expr/bitwise.c
index 139f25f86b802..1d46a97757dfd 100644
--- a/src/expr/bitwise.c
+++ b/src/expr/bitwise.c
@@ -220,14 +220,14 @@ nftnl_expr_bitwise_snprintf_bool(char *buf, size_t size,
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
ret = nftnl_data_reg_snprintf(buf + offset, remain, &bitwise->mask,
- NFTNL_OUTPUT_DEFAULT, 0, DATA_VALUE);
+ 0, DATA_VALUE);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
ret = snprintf(buf + offset, remain, ") ^ ");
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
ret = nftnl_data_reg_snprintf(buf + offset, remain, &bitwise->xor,
- NFTNL_OUTPUT_DEFAULT, 0, DATA_VALUE);
+ 0, DATA_VALUE);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
return offset;
@@ -243,7 +243,7 @@ nftnl_expr_bitwise_snprintf_shift(char *buf, size_t size, const char *op,
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
ret = nftnl_data_reg_snprintf(buf + offset, remain, &bitwise->data,
- NFTNL_OUTPUT_DEFAULT, 0, DATA_VALUE);
+ 0, DATA_VALUE);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
ret = snprintf(buf + offset, remain, ") ");
diff --git a/src/expr/cmp.c b/src/expr/cmp.c
index 6b1c0fa3ac97f..04b9f25806725 100644
--- a/src/expr/cmp.c
+++ b/src/expr/cmp.c
@@ -188,7 +188,7 @@ nftnl_expr_cmp_snprintf(char *buf, size_t size,
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
ret = nftnl_data_reg_snprintf(buf + offset, remain, &cmp->data,
- NFTNL_OUTPUT_DEFAULT, 0, DATA_VALUE);
+ 0, DATA_VALUE);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
return offset;
diff --git a/src/expr/data_reg.c b/src/expr/data_reg.c
index d3ccc612ce812..bafdc6f3dadd3 100644
--- a/src/expr/data_reg.c
+++ b/src/expr/data_reg.c
@@ -63,38 +63,19 @@ nftnl_data_reg_verdict_snprintf_def(char *buf, size_t size,
int nftnl_data_reg_snprintf(char *buf, size_t size,
const union nftnl_data_reg *reg,
- uint32_t output_format, uint32_t flags,
- int reg_type)
+ uint32_t flags, int reg_type)
{
switch(reg_type) {
case DATA_VALUE:
- switch(output_format) {
- case NFTNL_OUTPUT_DEFAULT:
- return nftnl_data_reg_value_snprintf_default(buf, size,
- reg, flags);
- case NFTNL_OUTPUT_JSON:
- case NFTNL_OUTPUT_XML:
- default:
- break;
- }
- break;
+ return nftnl_data_reg_value_snprintf_default(buf, size,
+ reg, flags);
case DATA_VERDICT:
case DATA_CHAIN:
- switch(output_format) {
- case NFTNL_OUTPUT_DEFAULT:
- return nftnl_data_reg_verdict_snprintf_def(buf, size,
- reg, flags);
- case NFTNL_OUTPUT_JSON:
- case NFTNL_OUTPUT_XML:
- default:
- break;
- }
- break;
+ return nftnl_data_reg_verdict_snprintf_def(buf, size,
+ reg, flags);
default:
- break;
+ return -1;
}
-
- return -1;
}
static int nftnl_data_parse_cb(const struct nlattr *attr, void *data)
diff --git a/src/expr/immediate.c b/src/expr/immediate.c
index 08ddd22a54c5f..241aad3b5507c 100644
--- a/src/expr/immediate.c
+++ b/src/expr/immediate.c
@@ -195,17 +195,17 @@ nftnl_expr_immediate_snprintf(char *buf, size_t len,
if (e->flags & (1 << NFTNL_EXPR_IMM_DATA)) {
ret = nftnl_data_reg_snprintf(buf + offset, remain, &imm->data,
- NFTNL_OUTPUT_DEFAULT, flags, DATA_VALUE);
+ flags, DATA_VALUE);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
} else if (e->flags & (1 << NFTNL_EXPR_IMM_VERDICT)) {
ret = nftnl_data_reg_snprintf(buf + offset, remain, &imm->data,
- NFTNL_OUTPUT_DEFAULT, flags, DATA_VERDICT);
+ flags, DATA_VERDICT);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
} else if (e->flags & (1 << NFTNL_EXPR_IMM_CHAIN)) {
ret = nftnl_data_reg_snprintf(buf + offset, remain, &imm->data,
- NFTNL_OUTPUT_DEFAULT, flags, DATA_CHAIN);
+ flags, DATA_CHAIN);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
}
diff --git a/src/expr/range.c b/src/expr/range.c
index a93b2ea74d6d4..eed48829a246d 100644
--- a/src/expr/range.c
+++ b/src/expr/range.c
@@ -195,11 +195,11 @@ static int nftnl_expr_range_snprintf(char *buf, size_t size,
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
ret = nftnl_data_reg_snprintf(buf + offset, remain, &range->data_from,
- NFTNL_OUTPUT_DEFAULT, 0, DATA_VALUE);
+ 0, DATA_VALUE);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
ret = nftnl_data_reg_snprintf(buf + offset, remain, &range->data_to,
- NFTNL_OUTPUT_DEFAULT, 0, DATA_VALUE);
+ 0, DATA_VALUE);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
return offset;
diff --git a/src/set_elem.c b/src/set_elem.c
index ad528e28475a7..061469a74789c 100644
--- a/src/set_elem.c
+++ b/src/set_elem.c
@@ -710,7 +710,6 @@ int nftnl_set_elem_snprintf_default(char *buf, size_t size,
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
ret = nftnl_data_reg_snprintf(buf + offset, remain, &e->key,
- NFTNL_OUTPUT_DEFAULT,
DATA_F_NOPFX, DATA_VALUE);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
@@ -719,7 +718,6 @@ int nftnl_set_elem_snprintf_default(char *buf, size_t size,
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
ret = nftnl_data_reg_snprintf(buf + offset, remain, &e->key_end,
- NFTNL_OUTPUT_DEFAULT,
DATA_F_NOPFX, DATA_VALUE);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
}
@@ -728,7 +726,6 @@ int nftnl_set_elem_snprintf_default(char *buf, size_t size,
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
ret = nftnl_data_reg_snprintf(buf + offset, remain, &e->data,
- NFTNL_OUTPUT_DEFAULT,
DATA_F_NOPFX, dregtype);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
--
2.30.1
next prev parent reply other threads:[~2021-03-09 15:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-09 15:45 [libnftnl PATCH 00/10] Kill non-default output leftovers Phil Sutter
2021-03-09 15:45 ` [libnftnl PATCH 01/10] expr: Fix snprintf buffer length updates Phil Sutter
2021-03-09 15:45 ` [libnftnl PATCH 02/10] obj/ct_expect: " Phil Sutter
2021-03-09 15:45 ` [libnftnl PATCH 03/10] obj/ct_timeout: " Phil Sutter
2021-03-09 15:45 ` [libnftnl PATCH 04/10] object: Fix for wrong parameter passed to snprintf callback Phil Sutter
2021-03-09 15:45 ` [libnftnl PATCH 05/10] expr: Check output type once and for all Phil Sutter
2021-03-09 15:45 ` Phil Sutter [this message]
2021-03-09 15:45 ` [libnftnl PATCH 07/10] obj: Drop type parameter from snprintf callback Phil Sutter
2021-03-09 15:45 ` [libnftnl PATCH 08/10] Drop pointless local variable in snprintf callbacks Phil Sutter
2021-03-09 15:45 ` [libnftnl PATCH 09/10] Get rid of single option switch statements Phil Sutter
2021-03-09 15:45 ` [libnftnl PATCH 10/10] ruleset: Eliminate tag and separator helpers Phil Sutter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210309154516.4987-7-phil@nwl.cc \
--to=phil@nwl.cc \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).