[PATCH libnftnl] src: remove unused str2XXX helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



After commit 80077787f8f2 ("src: remove json support"), these internal
functions are no longer used:

nftnl_str2hooknum
nftnl_str2ntoh
nftnl_str2cmp
str2ctkey
str2ctdir
str2exthdr_op
str2exthdr_type
str2meta_key
nftnl_str2nat
nftnl_str2range
str2rt_key
nftnl_str2hooknum

Signed-off-by: Zhongqiu Duan <dzq.aishenghu0@xxxxxxxxx>
---
 src/chain.c          | 11 -----------
 src/expr/byteorder.c | 12 ------------
 src/expr/cmp.c       | 20 --------------------
 src/expr/ct.c        | 27 ---------------------------
 src/expr/exthdr.c    | 27 ---------------------------
 src/expr/meta.c      | 13 -------------
 src/expr/nat.c       | 12 ------------
 src/expr/range.c     | 12 ------------
 src/expr/rt.c        | 13 -------------
 src/flowtable.c      | 11 -----------
 10 files changed, 158 deletions(-)

diff --git a/src/chain.c b/src/chain.c
index 7287dcd98e89..895108cddad5 100644
--- a/src/chain.c
+++ b/src/chain.c
@@ -739,17 +739,6 @@ int nftnl_chain_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_chain *c)
 	return ret;
 }
 
-static inline int nftnl_str2hooknum(int family, const char *hook)
-{
-	int hooknum;
-
-	for (hooknum = 0; hooknum < NF_INET_NUMHOOKS; hooknum++) {
-		if (strcmp(hook, nftnl_hooknum2str(family, hooknum)) == 0)
-			return hooknum;
-	}
-	return -1;
-}
-
 static int nftnl_chain_snprintf_default(char *buf, size_t remain,
 					const struct nftnl_chain *c)
 {
diff --git a/src/expr/byteorder.c b/src/expr/byteorder.c
index 903c775bf196..4171d0633728 100644
--- a/src/expr/byteorder.c
+++ b/src/expr/byteorder.c
@@ -179,18 +179,6 @@ static const char *bo2str(uint32_t type)
 	return expr_byteorder_str[type];
 }
 
-static inline int nftnl_str2ntoh(const char *op)
-{
-	if (strcmp(op, "ntoh") == 0)
-		return NFT_BYTEORDER_NTOH;
-	else if (strcmp(op, "hton") == 0)
-		return NFT_BYTEORDER_HTON;
-	else {
-		errno = EINVAL;
-		return -1;
-	}
-}
-
 static int
 nftnl_expr_byteorder_snprintf(char *buf, size_t remain,
 			      uint32_t flags, const struct nftnl_expr *e)
diff --git a/src/expr/cmp.c b/src/expr/cmp.c
index f55a8c0299e1..2908f56325b4 100644
--- a/src/expr/cmp.c
+++ b/src/expr/cmp.c
@@ -148,26 +148,6 @@ static const char *cmp2str(uint32_t op)
 	return expr_cmp_str[op];
 }
 
-static inline int nftnl_str2cmp(const char *op)
-{
-	if (strcmp(op, "eq") == 0)
-		return NFT_CMP_EQ;
-	else if (strcmp(op, "neq") == 0)
-		return NFT_CMP_NEQ;
-	else if (strcmp(op, "lt") == 0)
-		return NFT_CMP_LT;
-	else if (strcmp(op, "lte") == 0)
-		return NFT_CMP_LTE;
-	else if (strcmp(op, "gt") == 0)
-		return NFT_CMP_GT;
-	else if (strcmp(op, "gte") == 0)
-		return NFT_CMP_GTE;
-	else {
-		errno = EINVAL;
-		return -1;
-	}
-}
-
 static int
 nftnl_expr_cmp_snprintf(char *buf, size_t remain,
 			uint32_t flags, const struct nftnl_expr *e)
diff --git a/src/expr/ct.c b/src/expr/ct.c
index b01fbc58bd28..1c46dd97ba6c 100644
--- a/src/expr/ct.c
+++ b/src/expr/ct.c
@@ -177,18 +177,6 @@ static const char *ctkey2str(uint32_t ctkey)
 	return ctkey2str_array[ctkey];
 }
 
-static inline int str2ctkey(const char *ctkey)
-{
-	int i;
-
-	for (i = 0; i < NFT_CT_MAX; i++) {
-		if (strcmp(ctkey2str_array[i], ctkey) == 0)
-			return i;
-	}
-
-	return -1;
-}
-
 static const char *ctdir2str(uint8_t ctdir)
 {
 	switch (ctdir) {
@@ -201,21 +189,6 @@ static const char *ctdir2str(uint8_t ctdir)
 	}
 }
 
-static inline int str2ctdir(const char *str, uint8_t *ctdir)
-{
-	if (strcmp(str, "original") == 0) {
-		*ctdir = IP_CT_DIR_ORIGINAL;
-		return 0;
-	}
-
-	if (strcmp(str, "reply") == 0) {
-		*ctdir = IP_CT_DIR_REPLY;
-		return 0;
-	}
-
-	return -1;
-}
-
 static int
 nftnl_expr_ct_snprintf(char *buf, size_t remain,
 		       uint32_t flags, const struct nftnl_expr *e)
diff --git a/src/expr/exthdr.c b/src/expr/exthdr.c
index 339527dcd193..ddebe43eabf5 100644
--- a/src/expr/exthdr.c
+++ b/src/expr/exthdr.c
@@ -202,33 +202,6 @@ static const char *op2str(uint8_t op)
 	}
 }
 
-static inline int str2exthdr_op(const char* str)
-{
-	if (!strcmp(str, "tcpopt"))
-		return NFT_EXTHDR_OP_TCPOPT;
-	if (!strcmp(str, "ipv4"))
-		return NFT_EXTHDR_OP_IPV4;
-
-	/* if str == "ipv6" or anything else */
-	return NFT_EXTHDR_OP_IPV6;
-}
-
-static inline int str2exthdr_type(const char *str)
-{
-	if (strcmp(str, "hopopts") == 0)
-		return IPPROTO_HOPOPTS;
-	else if (strcmp(str, "routing") == 0)
-		return IPPROTO_ROUTING;
-	else if (strcmp(str, "fragment") == 0)
-		return IPPROTO_FRAGMENT;
-	else if (strcmp(str, "dstopts") == 0)
-		return IPPROTO_DSTOPTS;
-	else if (strcmp(str, "mh") == 0)
-		return IPPROTO_MH;
-
-	return -1;
-}
-
 static int
 nftnl_expr_exthdr_snprintf(char *buf, size_t len,
 			   uint32_t flags, const struct nftnl_expr *e)
diff --git a/src/expr/meta.c b/src/expr/meta.c
index 56d3ddaffa22..d1ff6c4d2339 100644
--- a/src/expr/meta.c
+++ b/src/expr/meta.c
@@ -173,19 +173,6 @@ static const char *meta_key2str(uint8_t key)
 	return "unknown";
 }
 
-static inline int str2meta_key(const char *str)
-{
-	int i;
-
-	for (i = 0; i < NFT_META_MAX; i++) {
-		if (strcmp(str, meta_key2str_array[i]) == 0)
-			return i;
-	}
-
-	errno = EINVAL;
-	return -1;
-}
-
 static int
 nftnl_expr_meta_snprintf(char *buf, size_t len,
 			 uint32_t flags, const struct nftnl_expr *e)
diff --git a/src/expr/nat.c b/src/expr/nat.c
index 3ce1aafda55e..f7e24cb34d51 100644
--- a/src/expr/nat.c
+++ b/src/expr/nat.c
@@ -202,18 +202,6 @@ static inline const char *nat2str(uint16_t nat)
 	}
 }
 
-static inline int nftnl_str2nat(const char *nat)
-{
-	if (strcmp(nat, "snat") == 0)
-		return NFT_NAT_SNAT;
-	else if (strcmp(nat, "dnat") == 0)
-		return NFT_NAT_DNAT;
-	else {
-		errno = EINVAL;
-		return -1;
-	}
-}
-
 static int
 nftnl_expr_nat_snprintf(char *buf, size_t remain,
 			uint32_t flags, const struct nftnl_expr *e)
diff --git a/src/expr/range.c b/src/expr/range.c
index b05724fc5fa4..50a8ed092e38 100644
--- a/src/expr/range.c
+++ b/src/expr/range.c
@@ -162,18 +162,6 @@ static const char *range2str(uint32_t op)
 	return expr_range_str[op];
 }
 
-static inline int nftnl_str2range(const char *op)
-{
-	if (strcmp(op, "eq") == 0)
-		return NFT_RANGE_EQ;
-	else if (strcmp(op, "neq") == 0)
-		return NFT_RANGE_NEQ;
-	else {
-		errno = EINVAL;
-		return -1;
-	}
-}
-
 static int nftnl_expr_range_snprintf(char *buf, size_t remain,
 				     uint32_t flags, const struct nftnl_expr *e)
 {
diff --git a/src/expr/rt.c b/src/expr/rt.c
index 633031e1427c..4f2e96b53cad 100644
--- a/src/expr/rt.c
+++ b/src/expr/rt.c
@@ -122,19 +122,6 @@ static const char *rt_key2str(uint8_t key)
 	return "unknown";
 }
 
-static inline int str2rt_key(const char *str)
-{
-	int i;
-
-	for (i = 0; i < NFT_RT_MAX; i++) {
-		if (strcmp(str, rt_key2str_array[i]) == 0)
-			return i;
-	}
-
-	errno = EINVAL;
-	return -1;
-}
-
 static int
 nftnl_expr_rt_snprintf(char *buf, size_t len,
 		       uint32_t flags, const struct nftnl_expr *e)
diff --git a/src/flowtable.c b/src/flowtable.c
index 2a8d374541b0..fbbe0a866368 100644
--- a/src/flowtable.c
+++ b/src/flowtable.c
@@ -488,17 +488,6 @@ static const char *nftnl_hooknum2str(int family, int hooknum)
 	return "unknown";
 }
 
-static inline int nftnl_str2hooknum(int family, const char *hook)
-{
-	int hooknum;
-
-	for (hooknum = 0; hooknum < NF_INET_NUMHOOKS; hooknum++) {
-		if (strcmp(hook, nftnl_hooknum2str(family, hooknum)) == 0)
-			return hooknum;
-	}
-	return -1;
-}
-
 EXPORT_SYMBOL(nftnl_flowtable_parse);
 int nftnl_flowtable_parse(struct nftnl_flowtable *c, enum nftnl_parse_type type,
 			  const char *data, struct nftnl_parse_err *err)
-- 
2.43.0





[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux