@@ -826,10 +826,10 @@ static inline int nftnl_str2hooknum(int family, const char *hook)
return -1;
}
-static int nftnl_chain_snprintf_default(char *buf, size_t size,
+static int nftnl_chain_snprintf_default(char *buf, size_t remain,
const struct nftnl_chain *c)
{
- int ret, remain = size, offset = 0, i;
+ int ret, offset = 0, i;
ret = snprintf(buf, remain, "%s %s %s use %u",
nftnl_family2str(c->family), c->table, c->name, c->use);
@@ -884,11 +884,11 @@ static int nftnl_chain_snprintf_default(char *buf, size_t size,
return offset;
}
-static int nftnl_chain_cmd_snprintf(char *buf, size_t size,
+static int nftnl_chain_cmd_snprintf(char *buf, size_t remain,
const struct nftnl_chain *c, 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:
@@ -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)
@@ -210,10 +210,10 @@ nftnl_expr_bitwise_parse(struct nftnl_expr *e, struct nlattr *attr)
}
static int
-nftnl_expr_bitwise_snprintf_bool(char *buf, size_t size,
+nftnl_expr_bitwise_snprintf_bool(char *buf, size_t remain,
const struct nftnl_expr_bitwise *bitwise)
{
- int remain = size, offset = 0, ret;
+ int offset = 0, ret;
ret = snprintf(buf, remain, "reg %u = ( reg %u & ",
bitwise->dreg, bitwise->sreg);
@@ -234,9 +234,9 @@ nftnl_expr_bitwise_snprintf_bool(char *buf, size_t size,
}
static int
-nftnl_expr_bitwise_snprintf_shift(char *buf, size_t size, const char *op,
+nftnl_expr_bitwise_snprintf_shift(char *buf, size_t remain, const char *op,
const struct nftnl_expr_bitwise *bitwise)
-{ int remain = size, offset = 0, ret;
+{ int offset = 0, ret;
ret = snprintf(buf, remain, "reg %u = ( reg %u %s ",
bitwise->dreg, bitwise->sreg, op);
@@ -198,11 +198,11 @@ static inline int nftnl_str2ntoh(const char *op)
}
static int
-nftnl_expr_byteorder_snprintf(char *buf, size_t size,
+nftnl_expr_byteorder_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
struct nftnl_expr_byteorder *byteorder = nftnl_expr_data(e);
- int remain = size, offset = 0, ret;
+ int offset = 0, ret;
ret = snprintf(buf, remain, "reg %u = %s(reg %u, %u, %u) ",
byteorder->dreg, bo2str(byteorder->op),
@@ -177,11 +177,11 @@ static inline int nftnl_str2cmp(const char *op)
}
static int
-nftnl_expr_cmp_snprintf(char *buf, size_t size,
+nftnl_expr_cmp_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
struct nftnl_expr_cmp *cmp = nftnl_expr_data(e);
- int remain = size, offset = 0, ret;
+ int offset = 0, ret;
ret = snprintf(buf, remain, "%s reg %u ",
cmp2str(cmp->op), cmp->sreg);
@@ -223,11 +223,11 @@ static inline int str2ctdir(const char *str, uint8_t *ctdir)
}
static int
-nftnl_expr_ct_snprintf(char *buf, size_t size,
+nftnl_expr_ct_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
- int ret, remain = size, offset = 0;
struct nftnl_expr_ct *ct = nftnl_expr_data(e);
+ int ret, offset = 0;
if (e->flags & (1 << NFTNL_EXPR_CT_SREG)) {
ret = snprintf(buf, remain, "set %s with reg %u ",
@@ -25,12 +25,12 @@
#include "internal.h"
static int
-nftnl_data_reg_value_snprintf_default(char *buf, size_t size,
+nftnl_data_reg_value_snprintf_default(char *buf, size_t remain,
const union nftnl_data_reg *reg,
uint32_t flags)
{
const char *pfx = flags & DATA_F_NOPFX ? "" : "0x";
- int remain = size, offset = 0, ret, i;
+ int offset = 0, ret, i;
@@ -111,11 +111,11 @@ static int nftnl_expr_dup_parse(struct nftnl_expr *e, struct nlattr *attr)
return ret;
}
-static int nftnl_expr_dup_snprintf(char *buf, size_t len,
+static int nftnl_expr_dup_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
- int remain = len, offset = 0, ret;
struct nftnl_expr_dup *dup = nftnl_expr_data(e);
+ int offset = 0, ret;
if (e->flags & (1 << NFTNL_EXPR_DUP_SREG_ADDR)) {
ret = snprintf(buf + offset, remain, "sreg_addr %u ", dup->sreg_addr);
@@ -308,12 +308,12 @@ static const char *op2str(enum nft_dynset_ops op)
}
static int
-nftnl_expr_dynset_snprintf(char *buf, size_t size,
+nftnl_expr_dynset_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
struct nftnl_expr_dynset *dynset = nftnl_expr_data(e);
struct nftnl_expr *expr;
- int remain = size, offset = 0, ret;
+ int offset = 0, ret;
ret = snprintf(buf, remain, "%s reg_key %u set %s ",
op2str(dynset->op), dynset->sreg_key, dynset->set_name);
@@ -143,13 +143,13 @@ static const char *fib_type_str(enum nft_fib_result r)
}
static int
-nftnl_expr_fib_snprintf(char *buf, size_t size,
+nftnl_expr_fib_snprintf(char *buf, size_t remain,
uint32_t printflags, const struct nftnl_expr *e)
{
struct nftnl_expr_fib *fib = nftnl_expr_data(e);
- int remain = size, offset = 0, ret, i;
uint32_t flags = fib->flags & ~NFTA_FIB_F_PRESENT;
uint32_t present_flag = fib->flags & NFTA_FIB_F_PRESENT;
+ int offset = 0, ret, i;
static const struct {
int bit;
const char *name;
@@ -92,11 +92,11 @@ static int nftnl_expr_flow_parse(struct nftnl_expr *e, struct nlattr *attr)
return ret;
}
-static int nftnl_expr_flow_snprintf(char *buf, size_t size,
+static int nftnl_expr_flow_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
- int remain = size, offset = 0, ret;
struct nftnl_expr_flow *l = nftnl_expr_data(e);
+ int offset = 0, ret;
ret = snprintf(buf, remain, "flowtable %s ", l->table_name);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
@@ -125,11 +125,11 @@ static int nftnl_expr_fwd_parse(struct nftnl_expr *e, struct nlattr *attr)
return ret;
}
-static int nftnl_expr_fwd_snprintf(char *buf, size_t len,
+static int nftnl_expr_fwd_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
- int remain = len, offset = 0, ret;
struct nftnl_expr_fwd *fwd = nftnl_expr_data(e);
+ int offset = 0, ret;
if (e->flags & (1 << NFTNL_EXPR_FWD_SREG_DEV)) {
ret = snprintf(buf + offset, remain, "sreg_dev %u ",
@@ -184,11 +184,11 @@ nftnl_expr_hash_parse(struct nftnl_expr *e, struct nlattr *attr)
}
static int
-nftnl_expr_hash_snprintf(char *buf, size_t size,
+nftnl_expr_hash_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
struct nftnl_expr_hash *hash = nftnl_expr_data(e);
- int remain = size, offset = 0, ret;
+ int offset = 0, ret;
switch (hash->type) {
case NFT_HASH_SYM:
@@ -184,11 +184,11 @@ nftnl_expr_immediate_parse(struct nftnl_expr *e, struct nlattr *attr)
}
static int
-nftnl_expr_immediate_snprintf(char *buf, size_t len,
+nftnl_expr_immediate_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
- int remain = len, offset = 0, ret;
struct nftnl_expr_immediate *imm = nftnl_expr_data(e);
+ int offset = 0, ret;
ret = snprintf(buf, remain, "reg %u ", imm->dreg);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
@@ -187,11 +187,11 @@ nftnl_expr_log_parse(struct nftnl_expr *e, struct nlattr *attr)
}
static int
-nftnl_expr_log_snprintf(char *buf, size_t size,
+nftnl_expr_log_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
struct nftnl_expr_log *log = nftnl_expr_data(e);
- int ret, offset = 0, remain = size;
+ int ret, offset = 0;
if (e->flags & (1 << NFTNL_EXPR_LOG_PREFIX)) {
ret = snprintf(buf, remain, "prefix %s ", log->prefix);
@@ -168,11 +168,11 @@ nftnl_expr_lookup_parse(struct nftnl_expr *e, struct nlattr *attr)
}
static int
-nftnl_expr_lookup_snprintf(char *buf, size_t size,
+nftnl_expr_lookup_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
- int remain = size, offset = 0, ret;
struct nftnl_expr_lookup *l = nftnl_expr_data(e);
+ int offset = 0, ret;
ret = snprintf(buf, remain, "reg %u set %s ", l->sreg, l->set_name);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
@@ -131,11 +131,11 @@ nftnl_expr_masq_parse(struct nftnl_expr *e, struct nlattr *attr)
return 0;
}
-static int nftnl_expr_masq_snprintf(char *buf, size_t len,
+static int nftnl_expr_masq_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
struct nftnl_expr_masq *masq = nftnl_expr_data(e);
- int remain = len, offset = 0, ret = 0;
+ int offset = 0, ret = 0;
if (e->flags & (1 << NFTNL_EXPR_MASQ_REG_PROTO_MIN)) {
ret = snprintf(buf + offset, remain, "proto_min reg %u ",
@@ -221,11 +221,11 @@ static inline int nftnl_str2nat(const char *nat)
}
static int
-nftnl_expr_nat_snprintf(char *buf, size_t size,
+nftnl_expr_nat_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
struct nftnl_expr_nat *nat = nftnl_expr_data(e);
- int remain = size, offset = 0, ret = 0;
+ int offset = 0, ret = 0;
ret = snprintf(buf, remain, "%s ", nat2str(nat->type));
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
@@ -143,11 +143,11 @@ nftnl_expr_ng_parse(struct nftnl_expr *e, struct nlattr *attr)
}
static int
-nftnl_expr_ng_snprintf(char *buf, size_t size,
+nftnl_expr_ng_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
struct nftnl_expr_ng *ng = nftnl_expr_data(e);
- int remain = size, offset = 0, ret;
+ int offset = 0, ret;
switch (ng->type) {
case NFT_NG_INCREMENTAL:
@@ -125,11 +125,11 @@ nftnl_expr_osf_parse(struct nftnl_expr *e, struct nlattr *attr)
}
static int
-nftnl_expr_osf_snprintf(char *buf, size_t size,
+nftnl_expr_osf_snprintf(char *buf, size_t len,
uint32_t flags, const struct nftnl_expr *e)
{
struct nftnl_expr_osf *osf = nftnl_expr_data(e);
- int ret, offset = 0, len = size;
+ int ret, offset = 0;
if (e->flags & (1 << NFTNL_EXPR_OSF_DREG)) {
ret = snprintf(buf, len, "dreg %u ", osf->dreg);
@@ -144,12 +144,12 @@ nftnl_expr_queue_parse(struct nftnl_expr *e, struct nlattr *attr)
}
static int
-nftnl_expr_queue_snprintf(char *buf, size_t len,
+nftnl_expr_queue_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
struct nftnl_expr_queue *queue = nftnl_expr_data(e);
- int ret, remain = len, offset = 0;
uint16_t total_queues;
+ int ret, offset = 0;
if (e->flags & (1 << NFTNL_EXPR_QUEUE_NUM)) {
total_queues = queue->queuenum + queue->queues_total - 1;
@@ -184,11 +184,11 @@ static inline int nftnl_str2range(const char *op)
}
}
-static int nftnl_expr_range_snprintf(char *buf, size_t size,
+static int nftnl_expr_range_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
struct nftnl_expr_range *range = nftnl_expr_data(e);
- int remain = size, offset = 0, ret;
+ int offset = 0, ret;
ret = snprintf(buf, remain, "%s reg %u ",
range2str(range->op), range->sreg);
@@ -132,10 +132,10 @@ nftnl_expr_redir_parse(struct nftnl_expr *e, struct nlattr *attr)
}
static int
-nftnl_expr_redir_snprintf(char *buf, size_t len,
+nftnl_expr_redir_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
- int ret, remain = len, offset = 0;
+ int ret, offset = 0;
struct nftnl_expr_redir *redir = nftnl_expr_data(e);
if (nftnl_expr_is_set(e, NFTNL_EXPR_REDIR_REG_PROTO_MIN)) {
@@ -128,11 +128,11 @@ nftnl_expr_synproxy_parse(struct nftnl_expr *e, struct nlattr *attr)
}
static int
-nftnl_expr_synproxy_snprintf(char *buf, size_t size,
+nftnl_expr_synproxy_snprintf(char *buf, size_t len,
uint32_t flags, const struct nftnl_expr *e)
{
struct nftnl_expr_synproxy *synproxy = nftnl_expr_data(e);
- int ret, offset = 0, len = size;
+ int ret, offset = 0;
if (e->flags & (1 << NFTNL_EXPR_SYNPROXY_MSS) &&
e->flags & (1 << NFTNL_EXPR_SYNPROXY_WSCALE)) {
@@ -135,11 +135,11 @@ nftnl_expr_tproxy_build(struct nlmsghdr *nlh, const struct nftnl_expr *e)
}
static int
-nftnl_expr_tproxy_snprintf(char *buf, size_t size,
+nftnl_expr_tproxy_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
struct nftnl_expr_tproxy *tproxy = nftnl_expr_data(e);
- int remain = size, offset = 0, ret = 0;
+ int offset = 0, ret = 0;
if (tproxy->family != NFTA_TPROXY_UNSPEC) {
ret = snprintf(buf + offset, remain, "%s ",
@@ -172,11 +172,11 @@ static const char *xfrmdir2str(uint8_t dir)
}
static int
-nftnl_expr_xfrm_snprintf(char *buf, size_t size,
+nftnl_expr_xfrm_snprintf(char *buf, size_t remain,
uint32_t flags, const struct nftnl_expr *e)
{
struct nftnl_expr_xfrm *x = nftnl_expr_data(e);
- int ret, remain = size, offset = 0;
+ int ret, offset = 0;
if (e->flags & (1 << NFTNL_EXPR_XFRM_DREG)) {
ret = snprintf(buf, remain, "load %s %u %s => reg %u ",
@@ -591,10 +591,10 @@ int nftnl_flowtable_parse_file(struct nftnl_flowtable *c,
return -1;
}
-static int nftnl_flowtable_snprintf_default(char *buf, size_t size,
+static int nftnl_flowtable_snprintf_default(char *buf, size_t remain,
const struct nftnl_flowtable *c)
{
- int ret, remain = size, offset = 0, i;
+ int ret, offset = 0, i;
ret = snprintf(buf, remain, "flow table %s %s use %u size %u flags %x",
c->table, c->name, c->use, c->size, c->ft_flags);
@@ -623,12 +623,12 @@ static int nftnl_flowtable_snprintf_default(char *buf, size_t size,
return offset;
}
-static int nftnl_flowtable_cmd_snprintf(char *buf, size_t size,
+static int nftnl_flowtable_cmd_snprintf(char *buf, size_t remain,
const struct nftnl_flowtable *c,
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:
@@ -156,15 +156,15 @@ int nftnl_gen_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_gen *gen)
return 0;
}
-static int nftnl_gen_cmd_snprintf(char *buf, size_t size,
+static int nftnl_gen_cmd_snprintf(char *buf, size_t remain,
const struct nftnl_gen *gen, 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:
- ret = snprintf(buf, size, "ruleset generation ID %u", gen->id);
+ ret = snprintf(buf, remain, "ruleset generation ID %u", gen->id);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
break;
default:
@@ -151,13 +151,12 @@ nftnl_obj_ct_expect_parse(struct nftnl_obj *e, struct nlattr *attr)
return 0;
}
-static int nftnl_obj_ct_expect_snprintf(char *buf, size_t len,
+static int nftnl_obj_ct_expect_snprintf(char *buf, size_t remain,
uint32_t flags,
const struct nftnl_obj *e)
{
- int ret = 0;
- int offset = 0, remain = len;
struct nftnl_obj_ct_expect *exp = nftnl_obj_data(e);
+ int ret = 0, offset = 0;
if (e->flags & (1 << NFTNL_OBJ_CT_EXPECT_L3PROTO)) {
ret = snprintf(buf + offset, remain,
@@ -257,12 +257,11 @@ nftnl_obj_ct_timeout_parse(struct nftnl_obj *e, struct nlattr *attr)
return 0;
}
-static int nftnl_obj_ct_timeout_snprintf(char *buf, size_t len,
+static int nftnl_obj_ct_timeout_snprintf(char *buf, size_t remain,
uint32_t flags,
const struct nftnl_obj *e)
{
- int ret = 0;
- int offset = 0, remain = len;
+ int ret = 0, offset = 0;
struct nftnl_obj_ct_timeout *timeout = nftnl_obj_data(e);
@@ -117,12 +117,12 @@ static int nftnl_obj_synproxy_parse(struct nftnl_obj *e, struct nlattr *attr)
return 0;
}
-static int nftnl_obj_synproxy_snprintf(char *buf, size_t size,
+static int nftnl_obj_synproxy_snprintf(char *buf, size_t len,
uint32_t flags,
const struct nftnl_obj *e)
{
struct nftnl_obj_synproxy *synproxy = nftnl_obj_data(e);
- int ret, offset = 0, len = size;
+ int ret, offset = 0;
if (e->flags & (1 << NFTNL_OBJ_SYNPROXY_MSS) &&
e->flags & (1 << NFTNL_OBJ_SYNPROXY_WSCALE)) {
@@ -384,14 +384,14 @@ int nftnl_obj_parse_file(struct nftnl_obj *obj, enum nftnl_parse_type type,
return nftnl_obj_do_parse(obj, type, fp, err, NFTNL_PARSE_FILE);
}
-static int nftnl_obj_snprintf_dflt(char *buf, size_t size,
+static int nftnl_obj_snprintf_dflt(char *buf, size_t remain,
const struct nftnl_obj *obj,
uint32_t type, uint32_t flags)
{
const char *name = obj->ops ? obj->ops->name : "(unknown)";
- int ret, remain = size, offset = 0;
+ int ret, offset = 0;
- ret = snprintf(buf, size, "table %s name %s use %u [ %s ",
+ ret = snprintf(buf, remain, "table %s name %s use %u [ %s ",
obj->table, obj->name, obj->use, name);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
@@ -405,11 +405,11 @@ static int nftnl_obj_snprintf_dflt(char *buf, size_t size,
return offset;
}
-static int nftnl_obj_cmd_snprintf(char *buf, size_t size,
+static int nftnl_obj_cmd_snprintf(char *buf, size_t remain,
const struct nftnl_obj *obj, 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:
@@ -545,12 +545,12 @@ int nftnl_rule_parse_file(struct nftnl_rule *r, enum nftnl_parse_type type,
return nftnl_rule_do_parse(r, type, fp, err, NFTNL_PARSE_FILE);
}
-static int nftnl_rule_snprintf_default(char *buf, size_t size,
+static int nftnl_rule_snprintf_default(char *buf, size_t remain,
const struct nftnl_rule *r,
uint32_t type, uint32_t flags)
{
struct nftnl_expr *expr;
- int ret, remain = size, offset = 0, i;
+ int ret, offset = 0, i;
const char *sep = "";
if (r->flags & (1 << NFTNL_RULE_FAMILY)) {
@@ -635,12 +635,12 @@ static int nftnl_rule_snprintf_default(char *buf, size_t size,
return offset;
}
-static int nftnl_rule_cmd_snprintf(char *buf, size_t size,
+static int nftnl_rule_cmd_snprintf(char *buf, size_t remain,
const struct nftnl_rule *r, uint32_t cmd,
uint32_t type, uint32_t flags)
{
- int ret, remain = size, offset = 0;
uint32_t inner_flags = flags;
+ int ret, offset = 0;
inner_flags &= ~NFTNL_OF_EVENT_ANY;
@@ -343,13 +343,13 @@ static const char *nftnl_ruleset_o_closetag(uint32_t type)
}
static int
-nftnl_ruleset_snprintf_table(char *buf, size_t size,
+nftnl_ruleset_snprintf_table(char *buf, size_t remain,
const struct nftnl_ruleset *rs, uint32_t type,
uint32_t flags)
{
struct nftnl_table *t;
struct nftnl_table_list_iter *ti;
- int ret, remain = size, offset = 0;
+ int ret, offset = 0;
ti = nftnl_table_list_iter_create(rs->table_list);
if (ti == NULL)
@@ -372,13 +372,13 @@ nftnl_ruleset_snprintf_table(char *buf, size_t size,
}
static int
-nftnl_ruleset_snprintf_chain(char *buf, size_t size,
+nftnl_ruleset_snprintf_chain(char *buf, size_t remain,
const struct nftnl_ruleset *rs, uint32_t type,
uint32_t flags)
{
struct nftnl_chain *c;
struct nftnl_chain_list_iter *ci;
- int ret, remain = size, offset = 0;
+ int ret, offset = 0;
ci = nftnl_chain_list_iter_create(rs->chain_list);
if (ci == NULL)
@@ -401,13 +401,13 @@ nftnl_ruleset_snprintf_chain(char *buf, size_t size,
}
static int
-nftnl_ruleset_snprintf_set(char *buf, size_t size,
+nftnl_ruleset_snprintf_set(char *buf, size_t remain,
const struct nftnl_ruleset *rs, uint32_t type,
uint32_t flags)
{
struct nftnl_set *s;
struct nftnl_set_list_iter *si;
- int ret, remain = size, offset = 0;
+ int ret, offset = 0;
si = nftnl_set_list_iter_create(rs->set_list);
if (si == NULL)
@@ -430,13 +430,13 @@ nftnl_ruleset_snprintf_set(char *buf, size_t size,
}
static int
-nftnl_ruleset_snprintf_rule(char *buf, size_t size,
+nftnl_ruleset_snprintf_rule(char *buf, size_t remain,
const struct nftnl_ruleset *rs, uint32_t type,
uint32_t flags)
{
struct nftnl_rule *r;
struct nftnl_rule_list_iter *ri;
- int ret, remain = size, offset = 0;
+ int ret, offset = 0;
ri = nftnl_rule_list_iter_create(rs->rule_list);
if (ri == NULL)
@@ -459,12 +459,13 @@ nftnl_ruleset_snprintf_rule(char *buf, size_t size,
}
static int
-nftnl_ruleset_do_snprintf(char *buf, size_t size, const struct nftnl_ruleset *rs,
- uint32_t cmd, uint32_t type, uint32_t flags)
+nftnl_ruleset_do_snprintf(char *buf, size_t remain,
+ const struct nftnl_ruleset *rs,
+ uint32_t cmd, uint32_t type, uint32_t flags)
{
- int ret, remain = size, offset = 0;
- void *prev = NULL;
uint32_t inner_flags = flags;
+ int ret, offset = 0;
+ void *prev = NULL;
/* dont pass events flags to child calls of _snprintf() */
inner_flags &= ~NFTNL_OF_EVENT_ANY;
@@ -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;
@@ -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:
@@ -367,11 +367,11 @@ static int nftnl_table_snprintf_default(char *buf, size_t size,
t->table_flags, t->use, (unsigned long long)t->handle);
}
-static int nftnl_table_cmd_snprintf(char *buf, size_t size,
+static int nftnl_table_cmd_snprintf(char *buf, size_t remain,
const struct nftnl_table *t, 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:
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> --- src/chain.c | 8 ++++---- src/expr.c | 6 +++--- src/expr/bitwise.c | 8 ++++---- src/expr/byteorder.c | 4 ++-- src/expr/cmp.c | 4 ++-- src/expr/ct.c | 4 ++-- src/expr/data_reg.c | 4 ++-- src/expr/dup.c | 4 ++-- src/expr/dynset.c | 4 ++-- src/expr/fib.c | 4 ++-- src/expr/flow_offload.c | 4 ++-- src/expr/fwd.c | 4 ++-- src/expr/hash.c | 4 ++-- src/expr/immediate.c | 4 ++-- src/expr/log.c | 4 ++-- src/expr/lookup.c | 4 ++-- src/expr/masq.c | 4 ++-- src/expr/nat.c | 4 ++-- src/expr/numgen.c | 4 ++-- src/expr/osf.c | 4 ++-- src/expr/queue.c | 4 ++-- src/expr/range.c | 4 ++-- src/expr/redir.c | 4 ++-- src/expr/synproxy.c | 4 ++-- src/expr/tproxy.c | 4 ++-- src/expr/xfrm.c | 4 ++-- src/flowtable.c | 8 ++++---- src/gen.c | 6 +++--- src/obj/ct_expect.c | 5 ++--- src/obj/ct_timeout.c | 5 ++--- src/obj/synproxy.c | 4 ++-- src/object.c | 10 +++++----- src/rule.c | 8 ++++---- src/ruleset.c | 25 +++++++++++++------------ src/set.c | 9 ++++----- src/set_elem.c | 9 ++++----- src/table.c | 4 ++-- 37 files changed, 102 insertions(+), 105 deletions(-)