diff options
author | Varsha Rao <rvarsha016@gmail.com> | 2017-09-20 21:53:08 +0530 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2017-09-27 14:00:13 +0200 |
commit | 676ea569bbe5abf750d9ed516f35c017efbdce5f (patch) | |
tree | c348c3f834009ef5edb881311b20f26a46b40307 /src/expr/log.c | |
parent | b808caea50a9de10530591b2e83c243d9fbf4855 (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/expr/log.c')
-rw-r--r-- | src/expr/log.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/expr/log.c b/src/expr/log.c index b642255..86d9651 100644 --- a/src/expr/log.c +++ b/src/expr/log.c @@ -229,44 +229,45 @@ static int nftnl_expr_log_snprintf_default(char *buf, size_t size, const struct nftnl_expr *e) { struct nftnl_expr_log *log = nftnl_expr_data(e); - int ret, offset = 0, len = size; + int ret, offset = 0, remain = size; if (e->flags & (1 << NFTNL_EXPR_LOG_PREFIX)) { - ret = snprintf(buf, len, "prefix %s ", log->prefix); - SNPRINTF_BUFFER_SIZE(ret, size, len, offset); + ret = snprintf(buf, remain, "prefix %s ", log->prefix); + SNPRINTF_BUFFER_SIZE(ret, remain, offset); } if (e->flags & (1 << NFTNL_EXPR_LOG_GROUP)) { - ret = snprintf(buf + offset, len, + ret = snprintf(buf + offset, remain, "group %u snaplen %u qthreshold %u ", log->group, log->snaplen, log->qthreshold); - SNPRINTF_BUFFER_SIZE(ret, size, len, offset); + SNPRINTF_BUFFER_SIZE(ret, remain, offset); } else { if (e->flags & (1 << NFTNL_EXPR_LOG_LEVEL)) { - ret = snprintf(buf + offset, len, "level %u ", + ret = snprintf(buf + offset, remain, "level %u ", log->level); - SNPRINTF_BUFFER_SIZE(ret, size, len, offset); + SNPRINTF_BUFFER_SIZE(ret, remain, offset); } if (e->flags & (1 << NFTNL_EXPR_LOG_FLAGS)) { if (log->flags & NF_LOG_TCPSEQ) { - ret = snprintf(buf + offset, len, "tcpseq "); - SNPRINTF_BUFFER_SIZE(ret, size, len, offset); + ret = snprintf(buf + offset, remain, "tcpseq "); + SNPRINTF_BUFFER_SIZE(ret, remain, offset); } if (log->flags & NF_LOG_TCPOPT) { - ret = snprintf(buf + offset, len, "tcpopt "); - SNPRINTF_BUFFER_SIZE(ret, size, len, offset); + ret = snprintf(buf + offset, remain, "tcpopt "); + SNPRINTF_BUFFER_SIZE(ret, remain, offset); } if (log->flags & NF_LOG_IPOPT) { - ret = snprintf(buf + offset, len, "ipopt "); - SNPRINTF_BUFFER_SIZE(ret, size, len, offset); + ret = snprintf(buf + offset, remain, "ipopt "); + SNPRINTF_BUFFER_SIZE(ret, remain, offset); } if (log->flags & NF_LOG_UID) { - ret = snprintf(buf + offset, len, "uid "); - SNPRINTF_BUFFER_SIZE(ret, size, len, offset); + ret = snprintf(buf + offset, remain, "uid "); + SNPRINTF_BUFFER_SIZE(ret, remain, offset); } if (log->flags & NF_LOG_MACDECODE) { - ret = snprintf(buf + offset, len, "macdecode "); - SNPRINTF_BUFFER_SIZE(ret, size, len, offset); + ret = snprintf(buf + offset, remain, + "macdecode "); + SNPRINTF_BUFFER_SIZE(ret, remain, offset); } } } |