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/expr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/expr.c') diff --git a/src/expr.c b/src/expr.c index 01c55cf..277bbde 100644 --- a/src/expr.c +++ b/src/expr.c @@ -270,13 +270,13 @@ err1: } EXPORT_SYMBOL(nftnl_expr_snprintf); -int nftnl_expr_snprintf(char *buf, size_t size, const struct nftnl_expr *expr, +int nftnl_expr_snprintf(char *buf, size_t remain, const struct nftnl_expr *expr, uint32_t type, uint32_t flags) { int ret; - unsigned int offset = 0, remain = size; + unsigned int offset = 0; - if (size) + if (remain) buf[0] = '\0'; if (!expr->ops->snprintf || type != NFTNL_OUTPUT_DEFAULT) -- cgit v1.2.3