netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Haller <thaller@redhat.com>
To: NetFilter <netfilter-devel@vger.kernel.org>
Cc: Thomas Haller <thaller@redhat.com>
Subject: [nft PATCH 3/4] libnftables: inline creation of nf_sock in nft_ctx_new()
Date: Mon, 10 Jul 2023 10:45:18 +0200	[thread overview]
Message-ID: <20230710084926.172198-4-thaller@redhat.com> (raw)
In-Reply-To: <20230710084926.172198-1-thaller@redhat.com>

The function only has one caller. It's not clear how to extend this in a
useful way, so that it makes sense to keep the initialization in a
separate function.

Simplify the code, by inlining and dropping the static function
nft_ctx_netlink_init(). There was only one caller.

Signed-off-by: Thomas Haller <thaller@redhat.com>
---
 src/libnftables.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/src/libnftables.c b/src/libnftables.c
index 5b3eb2dc3df4..79dfdfc7c6ec 100644
--- a/src/libnftables.c
+++ b/src/libnftables.c
@@ -186,11 +186,6 @@ void nft_ctx_clear_include_paths(struct nft_ctx *ctx)
 	ctx->include_paths = NULL;
 }
 
-static void nft_ctx_netlink_init(struct nft_ctx *ctx)
-{
-	ctx->nf_sock = nft_mnl_socket_open();
-}
-
 EXPORT_SYMBOL(nft_ctx_new);
 struct nft_ctx *nft_ctx_new(uint32_t flags)
 {
@@ -218,7 +213,7 @@ struct nft_ctx *nft_ctx_new(uint32_t flags)
 	ctx->output.error_fp = stderr;
 	init_list_head(&ctx->vars_ctx.indesc_list);
 
-	nft_ctx_netlink_init(ctx);
+	ctx->nf_sock = nft_mnl_socket_open();
 
 	return ctx;
 }
-- 
2.41.0


  parent reply	other threads:[~2023-07-10  8:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-10  8:45 [nft PATCH 0/4] libnftables: minor cleanups initalizing nf_sock instance of nft_ctx Thomas Haller
2023-07-10  8:45 ` [nft PATCH 1/4] libnftables: always initialize netlink socket in nft_ctx_new() Thomas Haller
2023-07-10  8:45 ` [nft PATCH 2/4] libnftables: drop unused argument nf_sock from nft_netlink() Thomas Haller
2023-07-10  8:45 ` Thomas Haller [this message]
2023-07-10  8:45 ` [nft PATCH 4/4] libnftables: drop check for nf_sock in nft_ctx_free() Thomas Haller
2023-07-10 16:22 ` [nft PATCH 0/4] libnftables: minor cleanups initalizing nf_sock instance of nft_ctx Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230710084926.172198-4-thaller@redhat.com \
    --to=thaller@redhat.com \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).