Skip to contentSkip to conversation

netlink: Use nftnl_expr_fprintf() in netlink_dump_expr()

PATCH Applied Phil Sutter 2 participants 2 messages Oct 4, 2017 – Oct 17, 2017 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 netlink: Use nftnl_expr_fprintf() in netlink_dump_expr()

This gets rid of the temporary buffer.

---
Please note that this patch depends on the previously submitted libnftnl patch "expr: Introduce nftnl_expr_fprintf()". Since that patch is obviously not contained in libnftnl-1.0.8, this one should not be applied until nftables-v0.8 has been released.

---
 src/netlink.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
src/netlink.c +2 -4
index d5d410a847624..c9859ef151213 100644
@@ -520,13 +520,11 @@ void netlink_dump_rule(const struct nftnl_rule *nlr, struct netlink_ctx *ctx)
 void netlink_dump_expr(const struct nftnl_expr *nle,
 		       FILE *fp, unsigned int debug_mask)
 {
-	char buf[4096];
-
 	if (!(debug_mask & DEBUG_NETLINK))
 		return;
 
-	nftnl_expr_snprintf(buf, sizeof(buf), nle, 0, 0);
-	fprintf(fp, "%s\n", buf);
+	nftnl_expr_fprintf(fp, nle, 0, 0);
+	fprintf(fp, "\n");
 }
 
 static int list_rule_cb(struct nftnl_rule *nlr, void *arg)
Signature · 1 line
2.13.1
maintainer Applied
#1 lore raw
Quoted 1 line · Phil Sutter

This gets rid of the temporary buffer.

Applied, thanks.