From patchwork Wed Oct 4 21:41:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 821486 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3y6q9107LLz9t2V for ; Thu, 5 Oct 2017 08:41:25 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750951AbdJDVlX (ORCPT ); Wed, 4 Oct 2017 17:41:23 -0400 Received: from orbyte.nwl.cc ([151.80.46.58]:52950 "EHLO orbyte.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750779AbdJDVlX (ORCPT ); Wed, 4 Oct 2017 17:41:23 -0400 Received: from localhost ([::1]:47492 helo=xsao) by orbyte.nwl.cc with esmtp (Exim 4.89) (envelope-from ) id 1dzrPt-0001Wv-WE; Wed, 04 Oct 2017 23:41:22 +0200 From: Phil Sutter To: Pablo Neira Ayuso Cc: netfilter-devel@vger.kernel.org Subject: [nft PATCH] netlink: Use nftnl_expr_fprintf() in netlink_dump_expr() Date: Wed, 4 Oct 2017 23:41:11 +0200 Message-Id: <20171004214111.2755-1-phil@nwl.cc> X-Mailer: git-send-email 2.13.1 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org This gets rid of the temporary buffer. Signed-off-by: Phil Sutter --- 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(-) 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)) 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)