[PATCH] define "i" only if attr is NFTNL_CHAIN_DEVICES. When attr isn't NFTNL_CHAIN_DEVICES, "i" is useless.

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

 



From: shixuantong <tongxiaoge1001@xxxxxxx>

---
 src/chain.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/chain.c b/src/chain.c
index dcfcd04..f88aa7f 100644
--- a/src/chain.c
+++ b/src/chain.c
@@ -150,8 +150,6 @@ bool nftnl_chain_is_set(const struct nftnl_chain *c, uint16_t attr)
 EXPORT_SYMBOL(nftnl_chain_unset);
 void nftnl_chain_unset(struct nftnl_chain *c, uint16_t attr)
 {
-	int i;
-
 	if (!(c->flags & (1 << attr)))
 		return;
 
@@ -181,7 +179,7 @@ void nftnl_chain_unset(struct nftnl_chain *c, uint16_t attr)
 		xfree(c->dev);
 		break;
 	case NFTNL_CHAIN_DEVICES:
-		for (i = 0; i < c->dev_array_len; i++)
+		for (int i = 0; i < c->dev_array_len; i++)
 			xfree(c->dev_array[i]);
 		xfree(c->dev_array);
 		break;
@@ -209,7 +207,7 @@ int nftnl_chain_set_data(struct nftnl_chain *c, uint16_t attr,
 			 const void *data, uint32_t data_len)
 {
 	const char **dev_array;
-	int len = 0, i;
+	int len = 0;
 
 	nftnl_assert_attr_exists(attr, NFTNL_CHAIN_MAX);
 	nftnl_assert_validate(data, nftnl_chain_validate, attr, data_len);
@@ -277,7 +275,7 @@ int nftnl_chain_set_data(struct nftnl_chain *c, uint16_t attr,
 			len++;
 
 		if (c->flags & (1 << NFTNL_CHAIN_DEVICES)) {
-			for (i = 0; i < c->dev_array_len; i++)
+			for (int i = 0; i < c->dev_array_len; i++)
 				xfree(c->dev_array[i]);
 			xfree(c->dev_array);
 		}
@@ -286,7 +284,7 @@ int nftnl_chain_set_data(struct nftnl_chain *c, uint16_t attr,
 		if (!c->dev_array)
 			return -1;
 
-		for (i = 0; i < len; i++)
+		for (int i = 0; i < len; i++)
 			c->dev_array[i] = strdup(dev_array[i]);
 
 		c->dev_array_len = len;
-- 
2.33.0




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

  Powered by Linux