summaryrefslogtreecommitdiffstats
path: root/src/ruleset.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2021-03-09 11:26:47 +0100
committerPhil Sutter <phil@nwl.cc>2021-03-15 12:23:20 +0100
commit960c8e6174374ee113b290c304365bf02ed346d6 (patch)
tree3c5b27821e29409822920e6113e1c3364ac5b4e9 /src/ruleset.c
parent4f6e671b462180ba9af12bd30211811b5fca8cb1 (diff)
Drop pointless local variable in snprintf callbacks
A common idiom among snprintf callbacks was to copy the unsigned parameter 'size' (or 'len') into a signed variable for further use. Though since snprintf() itself casts it to unsigned and SNPRINTF_BUFFER_SIZE() does not allow it to become negative, this is not needed. Drop the local variable and rename the parameter accordingly. Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'src/ruleset.c')
-rw-r--r--src/ruleset.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/ruleset.c b/src/ruleset.c
index 2468bd4..f904aa4 100644
--- a/src/ruleset.c
+++ b/src/ruleset.c
@@ -343,13 +343,13 @@ static const char *nftnl_ruleset_o_closetag(uint32_t type)
}
static int
-nftnl_ruleset_snprintf_table(char *buf, size_t size,
+nftnl_ruleset_snprintf_table(char *buf, size_t remain,
const struct nftnl_ruleset *rs, uint32_t type,
uint32_t flags)
{
struct nftnl_table *t;
struct nftnl_table_list_iter *ti;
- int ret, remain = size, offset = 0;
+ int ret, offset = 0;
ti = nftnl_table_list_iter_create(rs->table_list);
if (ti == NULL)
@@ -372,13 +372,13 @@ nftnl_ruleset_snprintf_table(char *buf, size_t size,
}
static int
-nftnl_ruleset_snprintf_chain(char *buf, size_t size,
+nftnl_ruleset_snprintf_chain(char *buf, size_t remain,
const struct nftnl_ruleset *rs, uint32_t type,
uint32_t flags)
{
struct nftnl_chain *c;
struct nftnl_chain_list_iter *ci;
- int ret, remain = size, offset = 0;
+ int ret, offset = 0;
ci = nftnl_chain_list_iter_create(rs->chain_list);
if (ci == NULL)
@@ -401,13 +401,13 @@ nftnl_ruleset_snprintf_chain(char *buf, size_t size,
}
static int
-nftnl_ruleset_snprintf_set(char *buf, size_t size,
+nftnl_ruleset_snprintf_set(char *buf, size_t remain,
const struct nftnl_ruleset *rs, uint32_t type,
uint32_t flags)
{
struct nftnl_set *s;
struct nftnl_set_list_iter *si;
- int ret, remain = size, offset = 0;
+ int ret, offset = 0;
si = nftnl_set_list_iter_create(rs->set_list);
if (si == NULL)
@@ -430,13 +430,13 @@ nftnl_ruleset_snprintf_set(char *buf, size_t size,
}
static int
-nftnl_ruleset_snprintf_rule(char *buf, size_t size,
+nftnl_ruleset_snprintf_rule(char *buf, size_t remain,
const struct nftnl_ruleset *rs, uint32_t type,
uint32_t flags)
{
struct nftnl_rule *r;
struct nftnl_rule_list_iter *ri;
- int ret, remain = size, offset = 0;
+ int ret, offset = 0;
ri = nftnl_rule_list_iter_create(rs->rule_list);
if (ri == NULL)
@@ -459,12 +459,13 @@ nftnl_ruleset_snprintf_rule(char *buf, size_t size,
}
static int
-nftnl_ruleset_do_snprintf(char *buf, size_t size, const struct nftnl_ruleset *rs,
- uint32_t cmd, uint32_t type, uint32_t flags)
+nftnl_ruleset_do_snprintf(char *buf, size_t remain,
+ const struct nftnl_ruleset *rs,
+ uint32_t cmd, uint32_t type, uint32_t flags)
{
- int ret, remain = size, offset = 0;
- void *prev = NULL;
uint32_t inner_flags = flags;
+ int ret, offset = 0;
+ void *prev = NULL;
/* dont pass events flags to child calls of _snprintf() */
inner_flags &= ~NFTNL_OF_EVENT_ANY;