summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/chain.c2
-rw-r--r--src/expr/lookup.c2
-rw-r--r--src/rule.c2
-rw-r--r--src/set.c9
-rw-r--r--src/set_elem.c2
-rw-r--r--src/table.c2
6 files changed, 11 insertions, 8 deletions
diff --git a/src/chain.c b/src/chain.c
index c06e552..fb5d218 100644
--- a/src/chain.c
+++ b/src/chain.c
@@ -471,7 +471,7 @@ static int nft_chain_snprintf_default(char *buf, size_t size, struct nft_chain *
{
return snprintf(buf, size, "family=%u table=%s chain=%s type=%s "
"hook=%u prio=%d policy=%d use=%d "
- "packets=%lu bytes=%lu\n",
+ "packets=%lu bytes=%lu",
c->family, c->table, c->name, c->type, c->hooknum,
c->prio, c->policy, c->use, c->packets, c->bytes);
}
diff --git a/src/expr/lookup.c b/src/expr/lookup.c
index 003554b..1046615 100644
--- a/src/expr/lookup.c
+++ b/src/expr/lookup.c
@@ -169,7 +169,7 @@ nft_rule_expr_lookup_snprintf_default(char *buf, size_t size,
{
int len = size, offset = 0, ret;
- ret = snprintf(buf, len, "set=%s sreg=%u dreg=%u\n",
+ ret = snprintf(buf, len, "set=%s sreg=%u dreg=%u",
l->set_name, l->sreg, l->dreg);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
diff --git a/src/rule.c b/src/rule.c
index 849cb41..3945676 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -494,8 +494,6 @@ static int nft_rule_snprintf_default(char *buf, size_t size, struct nft_rule *r,
ret = expr->ops->snprintf(buf+offset, len, type, flags, expr);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
}
- ret = snprintf(buf+offset-1, len, "\n");
- SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
return ret;
}
diff --git a/src/set.c b/src/set.c
index 9454ace..ef2d11d 100644
--- a/src/set.c
+++ b/src/set.c
@@ -270,10 +270,17 @@ int nft_set_snprintf(char *buf, size_t size, struct nft_set *s,
int len = size, offset = 0;
struct nft_set_elem *elem;
- ret = snprintf(buf, size, "set=%s table=%s flags=%x\n",
+ ret = snprintf(buf, size, "set=%s table=%s flags=%x",
s->name, s->table, s->set_flags);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
+ /* Empty set? Skip printinf of elements */
+ if (list_empty(&s->element_list))
+ return offset;
+
+ ret = snprintf(buf+offset, size, "\n");
+ SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
+
list_for_each_entry(elem, &s->element_list, head) {
ret = snprintf(buf+offset, size, "\t");
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
diff --git a/src/set_elem.c b/src/set_elem.c
index 980faed..a2669ad 100644
--- a/src/set_elem.c
+++ b/src/set_elem.c
@@ -347,8 +347,6 @@ int nft_set_elem_snprintf(char *buf, size_t size, struct nft_set_elem *e,
ret = snprintf(buf+offset, len, "%.8x ", e->data.val[i]);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
}
- ret = snprintf(buf+offset, size, "\n");
- SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
return offset;
}
diff --git a/src/table.c b/src/table.c
index c963e6e..2d72136 100644
--- a/src/table.c
+++ b/src/table.c
@@ -197,7 +197,7 @@ static int nft_table_snprintf_xml(char *buf, size_t size, struct nft_table *t)
static int nft_table_snprintf_default(char *buf, size_t size, struct nft_table *t)
{
- return snprintf(buf, size, "table=%s family=%u flags=%x\n",
+ return snprintf(buf, size, "table=%s family=%u flags=%x",
t->name, t->family, t->table_flags);
}