]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
libnftables: inline creation of nf_sock in nft_ctx_new()
authorThomas Haller <thaller@redhat.com>
Mon, 10 Jul 2023 08:45:18 +0000 (10:45 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 10 Jul 2023 16:21:19 +0000 (18:21 +0200)
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>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/libnftables.c

index 5b3eb2dc3df487f258cd73402ee37c181d901a2f..79dfdfc7c6ecde4559d8d9794c64ca79f3cb8d7b 100644 (file)
@@ -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;
 }