From 960c8e6174374ee113b290c304365bf02ed346d6 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 9 Mar 2021 11:26:47 +0100 Subject: 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 --- src/chain.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/chain.c') diff --git a/src/chain.c b/src/chain.c index aac9da6..7906bf4 100644 --- a/src/chain.c +++ b/src/chain.c @@ -826,10 +826,10 @@ static inline int nftnl_str2hooknum(int family, const char *hook) return -1; } -static int nftnl_chain_snprintf_default(char *buf, size_t size, +static int nftnl_chain_snprintf_default(char *buf, size_t remain, const struct nftnl_chain *c) { - int ret, remain = size, offset = 0, i; + int ret, offset = 0, i; ret = snprintf(buf, remain, "%s %s %s use %u", nftnl_family2str(c->family), c->table, c->name, c->use); @@ -884,11 +884,11 @@ static int nftnl_chain_snprintf_default(char *buf, size_t size, return offset; } -static int nftnl_chain_cmd_snprintf(char *buf, size_t size, +static int nftnl_chain_cmd_snprintf(char *buf, size_t remain, const struct nftnl_chain *c, uint32_t cmd, uint32_t type, uint32_t flags) { - int ret, remain = size, offset = 0; + int ret, offset = 0; switch (type) { case NFTNL_OUTPUT_DEFAULT: -- cgit v1.2.3