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/set.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/set.c') diff --git a/src/set.c b/src/set.c index a21df1f..021543e 100644 --- a/src/set.c +++ b/src/set.c @@ -784,13 +784,12 @@ int nftnl_set_parse_file(struct nftnl_set *s, enum nftnl_parse_type type, return nftnl_set_do_parse(s, type, fp, err, NFTNL_PARSE_FILE); } -static int nftnl_set_snprintf_default(char *buf, size_t size, +static int nftnl_set_snprintf_default(char *buf, size_t remain, const struct nftnl_set *s, uint32_t type, uint32_t flags) { - int ret; - int remain = size, offset = 0; struct nftnl_set_elem *elem; + int ret, offset = 0; ret = snprintf(buf, remain, "%s %s %x", s->name, s->table, s->set_flags); @@ -837,12 +836,12 @@ static int nftnl_set_snprintf_default(char *buf, size_t size, return offset; } -static int nftnl_set_cmd_snprintf(char *buf, size_t size, +static int nftnl_set_cmd_snprintf(char *buf, size_t remain, const struct nftnl_set *s, uint32_t cmd, uint32_t type, uint32_t flags) { - int ret, remain = size, offset = 0; uint32_t inner_flags = flags; + int ret, offset = 0; if (type == NFTNL_OUTPUT_XML) return 0; -- cgit v1.2.3