summaryrefslogtreecommitdiffstats
path: root/src/object.c
diff options
context:
space:
mode:
authorVarsha Rao <rvarsha016@gmail.com>2017-09-20 21:53:08 +0530
committerPablo Neira Ayuso <pablo@netfilter.org>2017-09-27 14:00:13 +0200
commit676ea569bbe5abf750d9ed516f35c017efbdce5f (patch)
treec348c3f834009ef5edb881311b20f26a46b40307 /src/object.c
parentb808caea50a9de10530591b2e83c243d9fbf4855 (diff)
src: Change parameters of SNPRINTF_BUFFER_SIZE macro.
SNPRINTF_BUFFER_SIZE() macro declaration and definition is changed so that it accepts three arguments ret, remain and offset. Parameters size and len are not required instead parameter remain keeps track of available space in the buffer. Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
Diffstat (limited to 'src/object.c')
-rw-r--r--src/object.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/object.c b/src/object.c
index 9dc5b41..d15ec10 100644
--- a/src/object.c
+++ b/src/object.c
@@ -425,18 +425,19 @@ static int nftnl_obj_snprintf_dflt(char *buf, size_t size,
uint32_t type, uint32_t flags)
{
const char *name = obj->ops ? obj->ops->name : "(unknown)";
- int ret, len = size, offset = 0;
+ int ret, remain = size, offset = 0;
ret = snprintf(buf, size, "table %s name %s use %u [ %s ",
obj->table, obj->name, obj->use, name);
- SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
+ SNPRINTF_BUFFER_SIZE(ret, remain, offset);
if (obj->ops) {
- ret = obj->ops->snprintf(buf + offset, offset, type, flags, obj);
- SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
+ ret = obj->ops->snprintf(buf + offset, offset, type, flags,
+ obj);
+ SNPRINTF_BUFFER_SIZE(ret, remain, offset);
}
ret = snprintf(buf + offset, offset, "]");
- SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
+ SNPRINTF_BUFFER_SIZE(ret, remain, offset);
return offset;
}
@@ -445,27 +446,27 @@ static int nftnl_obj_cmd_snprintf(char *buf, size_t size,
const struct nftnl_obj *obj, uint32_t cmd,
uint32_t type, uint32_t flags)
{
- int ret, len = size, offset = 0;
+ int ret, remain = size, offset = 0;
- ret = nftnl_cmd_header_snprintf(buf + offset, len, cmd, type, flags);
- SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
+ ret = nftnl_cmd_header_snprintf(buf + offset, remain, cmd, type, flags);
+ SNPRINTF_BUFFER_SIZE(ret, remain, offset);
switch (type) {
case NFTNL_OUTPUT_DEFAULT:
- ret = nftnl_obj_snprintf_dflt(buf + offset, len, obj, type,
+ ret = nftnl_obj_snprintf_dflt(buf + offset, remain, obj, type,
flags);
break;
case NFTNL_OUTPUT_JSON:
- ret = nftnl_obj_export(buf + offset, len, obj, type, flags);
+ ret = nftnl_obj_export(buf + offset, remain, obj, type, flags);
break;
case NFTNL_OUTPUT_XML:
default:
return -1;
}
- SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
+ SNPRINTF_BUFFER_SIZE(ret, remain, offset);
- ret = nftnl_cmd_footer_snprintf(buf + offset, len, cmd, type, flags);
- SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
+ ret = nftnl_cmd_footer_snprintf(buf + offset, remain, cmd, type, flags);
+ SNPRINTF_BUFFER_SIZE(ret, remain, offset);
return offset;
}