Skip to contentSkip to conversation

src: Removes unused functions.

PATCH In review Varsha Rao 2 participants 7 messages Aug 16, 2017 – Aug 19, 2017 netfilter

lore
Share & tools
lore

Varsha Rao

author
#0 lore raw

cover src: Removes unused functions.

This patch set removes structure xt_stmt_ops and the following functions, as they are not used.

chain_get_cb
cli_display
mnl_nft_chain_get
mnl_nft_rule_add
mnl_nft_rule_delete
mnl_nft_set_get
mnl_nft_table_get
mpz_get_be64
netlink_add_rule_list
netlink_dump_table
netlink_get_chain
netlink_get_set
netlink_get_table
netlink_list_chain
set_get_cb
table_get_cb
xt_stmt_alloc
xt_stmt_destroy
xt_stmt_print
xt_stmt_release
xt_stmt_xlate

Varsha Rao (5):
src: Remove xt_stmt_() functions.
src: gmputil: Remove mpz_get_be64() function.
src: cli: Remove cli_display() function.
src: netlink: Remove unused functions.
src: mnl: Remove unused functions.

 include/cli.h       |   1 -
 include/gmputil.h   |   1 -
 include/mnl.h       |  10 -----
 include/netlink.h   |  11 ------
 include/statement.h |   2 -
 include/xt.h        |   7 ----
 src/cli.c           |  26 -------------
 src/gmputil.c       |   5 ---
 src/mnl.c           |  94 -----------------------------------------------
 src/netlink.c       | 104 ----------------------------------------------------
 src/statement.c     |  23 ------------
 src/xt.c            |  74 -------------------------------------
 12 files changed, 358 deletions(-)
Signature · 1 line
2.13.5
author
#1 lore raw

PATCH 1/5 src: Remove xt_stmt_() functions.

Remove functions xt_stmt_alloc(), xt_stmt_release(), xt_stmt_xlate(), xt_stmt_print(), xt_stmt_destroy() as they are not used. Similarly, remove structure xt_stmt_ops.

---
 include/statement.h |  2 --
 include/xt.h        |  7 -----
 src/statement.c     | 23 -----------------
 src/xt.c            | 74 -----------------------------------------------------
 4 files changed, 106 deletions(-)
include/statement.h +0 -2
index 49fb109..61b5027 100644
@@ -195,8 +195,6 @@ struct xt_stmt {
 	void				*entry;
 };
 
-extern struct stmt *xt_stmt_alloc(const struct location *loc);
-
 /**
  * enum stmt_types - statement types
  *
include/xt.h +0 -7
index 753511e..dfdf9ee 100644
@@ -8,9 +8,6 @@ struct rule_pp_ctx;
 struct rule;
 
 #ifdef HAVE_LIBXTABLES
-void xt_stmt_xlate(const struct stmt *stmt);
-void xt_stmt_release(const struct stmt *stmt);
-
 void netlink_parse_target(struct netlink_parse_ctx *ctx,
 			  const struct location *loc,
 			  const struct nftnl_expr *nle);
@@ -20,9 +17,6 @@ void netlink_parse_match(struct netlink_parse_ctx *ctx,
 void stmt_xt_postprocess(struct rule_pp_ctx *rctx, struct stmt *stmt,
 			 struct rule *rule);
 #else
-static inline void xt_stmt_xlate(const struct stmt *stmt) {}
-static inline void xt_stmt_release(const struct stmt *stmt) {}
-
 #include <erec.h>
 
 static inline void netlink_parse_target(struct netlink_parse_ctx *ctx,
@@ -35,5 +29,4 @@ static inline void stmt_xt_postprocess(struct rule_pp_ctx *rctx,
 				       struct stmt *stmt, struct rule *rule) {}
 
 #endif
-
 #endif /* _NFT_XT_H_ */
src/statement.c +0 -23
index 0ce875e..58f8aaf 100644
@@ -689,26 +689,3 @@ struct stmt *fwd_stmt_alloc(const struct location *loc)
 	return stmt_alloc(loc, &fwd_stmt_ops);
 }
 
-static void xt_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
-{
-	xt_stmt_xlate(stmt);
-}
-
-static void xt_stmt_destroy(struct stmt *stmt)
-{
-	xfree(stmt->xt.name);
-	xfree(stmt->xt.opts);
-	xt_stmt_release(stmt);
-}
-
-static const struct stmt_ops xt_stmt_ops = {
-	.type		= STMT_XT,
-	.name		= "xt",
-	.print		= xt_stmt_print,
-	.destroy	= xt_stmt_destroy,
-};
-
-struct stmt *xt_stmt_alloc(const struct location *loc)
-{
-	return stmt_alloc(loc, &xt_stmt_ops);
-}
src/xt.c +0 -74

92 lines not on this page · raw message

Signature · 1 line
2.13.5
author
#2 lore raw

PATCH 2/5 src: gmputil: Remove mpz_get_be64() function.

In reply to Varsha Rao

mpz_get_be64() is not used anywhere in source code. So remove it.

---
 include/gmputil.h | 1 -
 src/gmputil.c     | 5 -----
 2 files changed, 6 deletions(-)
include/gmputil.h +0 -1
index 1bf696a..9c37221 100644
@@ -45,7 +45,6 @@ extern uint32_t mpz_get_uint32(const mpz_t op);
 extern uint16_t mpz_get_uint16(const mpz_t op);
 extern uint8_t mpz_get_uint8(const mpz_t op);
 
-extern uint64_t mpz_get_be64(const mpz_t op);
 extern uint32_t mpz_get_be32(const mpz_t op);
 extern uint16_t mpz_get_be16(const mpz_t op);
 
src/gmputil.c +0 -5
index 844ea61..3cc4e61 100644
@@ -77,11 +77,6 @@ uint8_t mpz_get_uint8(const mpz_t op)
 	return mpz_get_type(uint8_t, MPZ_HOST_ENDIAN, op);
 }
 
-uint64_t mpz_get_be64(const mpz_t op)
-{
-	return mpz_get_type(uint64_t, MPZ_BIG_ENDIAN, op);
-}
-
 uint32_t mpz_get_be32(const mpz_t op)
 {
 	return mpz_get_type(uint32_t, MPZ_BIG_ENDIAN, op);
Signature · 1 line
2.13.5
author
#3 lore raw

PATCH 3/5 src: cli: Remove cli_display() function.

In reply to Varsha Rao

Remove cli_display() function, as it is not called anywhere in source code.

---
 include/cli.h |  1 -
 src/cli.c     | 26 --------------------------
 2 files changed, 27 deletions(-)
include/cli.h +0 -1
index e577400..40fc63e 100644
@@ -15,6 +15,5 @@ static inline int cli_init(struct nft_ctx *nft, struct mnl_socket *nf_sock,
 }
 #endif
 extern void cli_exit(void);
-extern void cli_display(const char *fmt, va_list ap) __fmtstring(1, 0);
 
 #endif
src/cli.c +0 -26
index a50fc58..d0ca9af 100644
@@ -149,32 +149,6 @@ static char **cli_completion(const char *text, int start, int end)
 	return NULL;
 }
 
-void __fmtstring(1, 0) cli_display(const char *fmt, va_list ap)
-{
-	int point, end;
-	char *buf;
-
-	point = rl_point;
-	end   = rl_end;
-	rl_point = rl_end = 0;
-
-	rl_save_prompt();
-	rl_clear_message();
-
-	if (vasprintf(&buf, fmt, ap) < 0)
-		fprintf(rl_outstream, "cli_display: out of memory\n");
-	else {
-		fprintf(rl_outstream, "%s\n", buf);
-		xfree(buf);
-	}
-
-	rl_restore_prompt();
-
-	rl_point = point;
-	rl_end   = end;
-	rl_forced_update_display();
-}
-
 int cli_init(struct nft_ctx *nft, struct mnl_socket *nf_sock,
 	     struct nft_cache *cache, struct parser_state *_state)
 {
Signature · 1 line
2.13.5
author
#4 lore raw

PATCH 4/5 src: netlink: Remove unused functions.

In reply to Varsha Rao

Remove netlink_add_rule_list(), netlink_dump_table(), netlink_get_chain(), netlink_get_set(), netlink_get_table(), netlink_list_chain() functions definitions as they are not called anywhere in source code.

---
 include/netlink.h |  11 ------
 src/netlink.c     | 104 ------------------------------------------------------
 2 files changed, 115 deletions(-)
include/netlink.h +0 -11
index 0e1d26b..4bed0e0 100644
@@ -111,8 +111,6 @@ extern int netlink_add_rule(struct netlink_ctx *ctx, const struct handle *h,
 			    const struct rule *rule, uint32_t flags);
 extern int netlink_delete_rule(struct netlink_ctx *ctx, const struct handle *h,
 			       const struct location *loc);
-extern int netlink_add_rule_list(struct netlink_ctx *ctx, const struct handle *h,
-				 const struct list_head *rule_list);
 extern int netlink_add_rule_batch(struct netlink_ctx *ctx,
 				  const struct handle *h,
 				  const struct rule *rule, uint32_t flags);
@@ -133,10 +131,6 @@ extern int netlink_delete_chain(struct netlink_ctx *ctx, const struct handle *h,
 				const struct location *loc);
 extern int netlink_list_chains(struct netlink_ctx *ctx, const struct handle *h,
 			       const struct location *loc);
-extern int netlink_get_chain(struct netlink_ctx *ctx, const struct handle *h,
-			     const struct location *loc);
-extern int netlink_list_chain(struct netlink_ctx *ctx, const struct handle *h,
-			      const struct location *loc);
 extern int netlink_flush_chain(struct netlink_ctx *ctx, const struct handle *h,
 			       const struct location *loc);
 
@@ -147,8 +141,6 @@ extern int netlink_delete_table(struct netlink_ctx *ctx, const struct handle *h,
 				const struct location *loc);
 extern int netlink_list_tables(struct netlink_ctx *ctx, const struct handle *h,
 			       const struct location *loc);
-extern int netlink_get_table(struct netlink_ctx *ctx, const struct handle *h,
-			     const struct location *loc, struct table *table);
 extern int netlink_list_table(struct netlink_ctx *ctx, const struct handle *h,
 			      const struct location *loc);
 extern int netlink_flush_table(struct netlink_ctx *ctx, const struct handle *h,
@@ -160,8 +152,6 @@ extern int netlink_delete_set(struct netlink_ctx *ctx, const struct handle *h,
 			      const struct location *loc);
 extern int netlink_list_sets(struct netlink_ctx *ctx, const struct handle *h,
 			     const struct location *loc);
-extern int netlink_get_set(struct netlink_ctx *ctx, const struct handle *h,
-			   const struct location *loc);
 
 extern struct stmt *netlink_parse_set_expr(const struct set *set,
 					   const struct nft_cache *cache,
@@ -186,7 +176,6 @@ extern int netlink_add_obj(struct netlink_ctx *ctx, const struct handle *h,
 extern int netlink_delete_obj(struct netlink_ctx *ctx, const struct handle *h,
 			      struct location *loc, uint32_t type);
 
-extern void netlink_dump_table(const struct nftnl_table *nlt);
 extern void netlink_dump_chain(const struct nftnl_chain *nlc);
 extern void netlink_dump_rule(const struct nftnl_rule *nlr);
 extern void netlink_dump_expr(const struct nftnl_expr *nle);
src/netlink.c +0 -104

134 lines not on this page · raw message

Signature · 1 line
2.13.5
author
#5 lore raw

PATCH 5/5 src: mnl: Remove unused functions.

In reply to Varsha Rao

Functions mnl_nft_chain_get(), mnl_nft_rule_add(), mnl_nft_rule_delete(), mnl_nft_set_get(), mnl_nft_table_get(), set_get_cb(), table_get_cb() and chain_get_cb() are only defined but not used, so remove them.

---
 include/mnl.h | 10 -------
 src/mnl.c     | 94 -----------------------------------------------------------
 2 files changed, 104 deletions(-)
include/mnl.h +0 -10
index 7df0823..affbf74 100644
@@ -33,10 +33,6 @@ int mnl_nft_rule_batch_del(struct nftnl_rule *nlr, struct nftnl_batch *batch,
 int mnl_nft_rule_batch_replace(struct nftnl_rule *nlr, struct nftnl_batch *batch,
 			       unsigned int flags, uint32_t seqnum);
 
-int mnl_nft_rule_add(struct mnl_socket *nf_sock, struct nftnl_rule *r,
-		     unsigned int flags, uint32_t seqnum);
-int mnl_nft_rule_delete(struct mnl_socket *nf_sock, struct nftnl_rule *r,
-			unsigned int flags, uint32_t seqnum);
 struct nftnl_rule_list *mnl_nft_rule_dump(struct mnl_socket *nf_sock,
 					  int family, uint32_t seqnum);
 
@@ -50,8 +46,6 @@ int mnl_nft_chain_batch_del(struct nftnl_chain *nlc, struct nftnl_batch *batch,
 			    unsigned int flags, uint32_t seqnum);
 struct nftnl_chain_list *mnl_nft_chain_dump(struct mnl_socket *nf_sock,
 					    int family, uint32_t seqnum);
-int mnl_nft_chain_get(struct mnl_socket *nf_sock, struct nftnl_chain *nlc,
-		      unsigned int flags, uint32_t seqnum);
 
 int mnl_nft_table_add(struct mnl_socket *nf_sock, struct nftnl_table *nlt,
 		      unsigned int flags, uint32_t seqnum);
@@ -63,8 +57,6 @@ int mnl_nft_table_batch_del(struct nftnl_table *nlt, struct nftnl_batch *batch,
 			    unsigned int flags, uint32_t seqnum);
 struct nftnl_table_list *mnl_nft_table_dump(struct mnl_socket *nf_sock,
 					    int family, uint32_t seqnum);
-int mnl_nft_table_get(struct mnl_socket *nf_sock, struct nftnl_table *nlt,
-		      unsigned int flags, uint32_t seqnum);
 
 int mnl_nft_set_add(struct mnl_socket *nf_sock, struct nftnl_set *nls,
 		    unsigned int flags, uint32_t seqnum);
@@ -76,8 +68,6 @@ int mnl_nft_set_batch_del(struct nftnl_set *nls, struct nftnl_batch *batch,
 			  unsigned int flags, uint32_t seqnum);
 struct nftnl_set_list *mnl_nft_set_dump(struct mnl_socket *nf_sock, int family,
 					const char *table, uint32_t seqnum);
-int mnl_nft_set_get(struct mnl_socket *nf_sock, struct nftnl_set *nls,
-		    uint32_t seqnum);
 
 int mnl_nft_setelem_add(struct mnl_socket *nf_sock, struct nftnl_set *nls,
 			unsigned int flags, uint32_t seqnum);
src/mnl.c +0 -94

118 lines not on this page · raw message

Signature · 1 line
2.13.5
#6 lore raw
In reply to Varsha Rao
Quoted 2 lines · Varsha Rao

This patch set removes structure xt_stmt_ops and the following functions, as they are not used.

Series applied, thanks Varsha.

Please, follow up with patches in case there is any fallout from this update.