diff options
author | Phil Sutter <phil@nwl.cc> | 2021-03-09 11:26:47 +0100 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2021-03-15 12:23:20 +0100 |
commit | 960c8e6174374ee113b290c304365bf02ed346d6 (patch) | |
tree | 3c5b27821e29409822920e6113e1c3364ac5b4e9 /src/set_elem.c | |
parent | 4f6e671b462180ba9af12bd30211811b5fca8cb1 (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/set_elem.c')
-rw-r--r-- | src/set_elem.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/set_elem.c b/src/set_elem.c index 061469a..a1764e2 100644 --- a/src/set_elem.c +++ b/src/set_elem.c @@ -698,13 +698,12 @@ int nftnl_set_elem_parse_file(struct nftnl_set_elem *e, enum nftnl_parse_type ty return -1; } -int nftnl_set_elem_snprintf_default(char *buf, size_t size, +int nftnl_set_elem_snprintf_default(char *buf, size_t remain, const struct nftnl_set_elem *e, enum nft_data_types dtype) { int dregtype = (dtype == NFT_DATA_VERDICT) ? DATA_VERDICT : DATA_VALUE; - - int ret, remain = size, offset = 0, i; + int ret, offset = 0, i; ret = snprintf(buf, remain, "element "); SNPRINTF_BUFFER_SIZE(ret, remain, offset); @@ -751,12 +750,12 @@ int nftnl_set_elem_snprintf_default(char *buf, size_t size, return offset; } -static int nftnl_set_elem_cmd_snprintf(char *buf, size_t size, +static int nftnl_set_elem_cmd_snprintf(char *buf, size_t remain, const struct nftnl_set_elem *e, 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: |