[nft] netlink: Use nftnl_expr_fprintf() in netlink_dump_expr()

Message ID 20171004214111.2755-1-phil@nwl.cc
State Accepted
Delegated to: Pablo Neira
Headers show
  • [nft] netlink: Use nftnl_expr_fprintf() in netlink_dump_expr()
Related show

Commit Message

Phil Sutter Oct. 4, 2017, 9:41 p.m.
This gets rid of the temporary buffer.

Signed-off-by: Phil Sutter <phil@nwl.cc>
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(-)


Pablo Neira Ayuso Oct. 17, 2017, 1:20 p.m. | #1
On Wed, Oct 04, 2017 at 11:41:11PM +0200, Phil Sutter wrote:
> This gets rid of the temporary buffer.

Applied, thanks.
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


diff --git a/src/netlink.c b/src/netlink.c
index d5d410a847624..c9859ef151213 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -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))
-	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)