[iptables PATCH 23/28] Fix a few cases of pointless assignments

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

 



This gets rid of a number of assignments which are either redundant or
not used afterwards.

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 iptables/ip6tables-restore.c    |  4 ++--
 iptables/iptables-restore.c     |  4 ++--
 iptables/iptables-xml.c         |  4 ++--
 iptables/nft.c                  |  2 --
 iptables/xtables-eb-translate.c |  1 -
 iptables/xtables-eb.c           |  3 ---
 iptables/xtables-restore.c      |  4 ++--
 libxtables/xtoptions.c          |  2 +-
 utils/nfnl_osf.c                | 13 +++++--------
 9 files changed, 14 insertions(+), 23 deletions(-)

diff --git a/iptables/ip6tables-restore.c b/iptables/ip6tables-restore.c
index 2bb303ac755b6..3706b981a806a 100644
--- a/iptables/ip6tables-restore.c
+++ b/iptables/ip6tables-restore.c
@@ -316,14 +316,14 @@ int ip6tables_restore_main(int argc, char *argv[])
 
 		} else if (in_table) {
 			int a;
-			char *ptr = buffer;
 			char *pcnt = NULL;
 			char *bcnt = NULL;
 			char *parsestart;
 
 			if (buffer[0] == '[') {
 				/* we have counters in our input */
-				ptr = strchr(buffer, ']');
+				char *ptr = strchr(buffer, ']');
+
 				if (!ptr)
 					xtables_error(PARAMETER_PROBLEM,
 						   "Bad line %u: need ]\n",
diff --git a/iptables/iptables-restore.c b/iptables/iptables-restore.c
index 5c211d07fa453..daee5fd99564a 100644
--- a/iptables/iptables-restore.c
+++ b/iptables/iptables-restore.c
@@ -314,14 +314,14 @@ iptables_restore_main(int argc, char *argv[])
 
 		} else if (in_table) {
 			int a;
-			char *ptr = buffer;
 			char *pcnt = NULL;
 			char *bcnt = NULL;
 			char *parsestart;
 
 			if (buffer[0] == '[') {
 				/* we have counters in our input */
-				ptr = strchr(buffer, ']');
+				char *ptr = strchr(buffer, ']');
+
 				if (!ptr)
 					xtables_error(PARAMETER_PROBLEM,
 						   "Bad line %u: need ]\n",
diff --git a/iptables/iptables-xml.c b/iptables/iptables-xml.c
index 788a67c608ec6..07300efc25eb4 100644
--- a/iptables/iptables-xml.c
+++ b/iptables/iptables-xml.c
@@ -648,7 +648,6 @@ iptables_xml_main(int argc, char *argv[])
 			ret = 1;
 		} else if (curTable[0]) {
 			unsigned int a;
-			char *ptr = buffer;
 			char *pcnt = NULL;
 			char *bcnt = NULL;
 			char *parsestart;
@@ -661,7 +660,8 @@ iptables_xml_main(int argc, char *argv[])
 
 			if (buffer[0] == '[') {
 				/* we have counters in our input */
-				ptr = strchr(buffer, ']');
+				char *ptr = strchr(buffer, ']');
+
 				if (!ptr)
 					xtables_error(PARAMETER_PROBLEM,
 						   "Bad line %u: need ]\n",
diff --git a/iptables/nft.c b/iptables/nft.c
index 032c3788a20a7..b81f41ab5350b 100644
--- a/iptables/nft.c
+++ b/iptables/nft.c
@@ -2169,8 +2169,6 @@ int nft_rule_delete_num(struct nft_handle *h, const char *chain,
 
 	r = nft_rule_find(h, list, chain, table, NULL, rulenum);
 	if (r != NULL) {
-		ret = 1;
-
 		DEBUGP("deleting rule by number %d\n", rulenum);
 		ret = __nft_rule_del(h, list, r);
 		if (ret < 0)
diff --git a/iptables/xtables-eb-translate.c b/iptables/xtables-eb-translate.c
index fb37b56ec23ce..07d6177627df2 100644
--- a/iptables/xtables-eb-translate.c
+++ b/iptables/xtables-eb-translate.c
@@ -332,7 +332,6 @@ print_zero:
 			if (OPT_COMMANDS)
 				xtables_error(PARAMETER_PROBLEM,
 					      "Multiple commands are not allowed");
-			command = 'V';
 			if (exec_style == EXEC_STYLE_DAEMON)
 				xtables_error(PARAMETER_PROBLEM,
 					      "%s %s\n", prog_name, prog_vers);
diff --git a/iptables/xtables-eb.c b/iptables/xtables-eb.c
index 820779315f6e5..99b6cbe95fb91 100644
--- a/iptables/xtables-eb.c
+++ b/iptables/xtables-eb.c
@@ -817,7 +817,6 @@ int do_commandeb(struct nft_handle *h, int argc, char *argv[], char **table,
 {
 	char *buffer;
 	int c, i;
-	int zerochain = -1; /* Needed for the -Z option (we can have -Z <this> -L <that>) */
 	int chcounter = 0; /* Needed for -C */
 	int rule_nr = 0;
 	int rule_nr_end = 0;
@@ -968,7 +967,6 @@ print_zero:
 			if (OPT_COMMANDS)
 				xtables_error(PARAMETER_PROBLEM,
 					      "Multiple commands are not allowed");
-			command = 'V';
 			printf("%s %s (nf_tables)\n", prog_name, prog_vers);
 			exit(0);
 		case 'h': /* Help */
@@ -1303,7 +1301,6 @@ print_zero:
 				 flags&LIST_C);
 	}
 	if (flags & OPT_ZERO) {
-		selected_chain = zerochain;
 		ret = nft_chain_zero_counters(h, chain, *table, 0);
 	} else if (command == 'F') {
 		ret = nft_rule_flush(h, chain, *table, 0);
diff --git a/iptables/xtables-restore.c b/iptables/xtables-restore.c
index 9d15593f95eed..d9faa4d01ca4a 100644
--- a/iptables/xtables-restore.c
+++ b/iptables/xtables-restore.c
@@ -266,7 +266,6 @@ void xtables_restore_parse(struct nft_handle *h,
 
 		} else if (in_table) {
 			int a;
-			char *ptr = buffer;
 			char *pcnt = NULL;
 			char *bcnt = NULL;
 			char *parsestart;
@@ -276,7 +275,8 @@ void xtables_restore_parse(struct nft_handle *h,
 
 			if (buffer[0] == '[') {
 				/* we have counters in our input */
-				ptr = strchr(buffer, ']');
+				char *ptr = strchr(buffer, ']');
+
 				if (!ptr)
 					xtables_error(PARAMETER_PROBLEM,
 						   "Bad line %u: need ]\n",
diff --git a/libxtables/xtoptions.c b/libxtables/xtoptions.c
index 05887a05eab71..d329f2ff7979e 100644
--- a/libxtables/xtoptions.c
+++ b/libxtables/xtoptions.c
@@ -286,7 +286,7 @@ static void xtopt_mint_value_to_ptr(struct xt_option_call *cb, void **datap,
 static void xtopt_parse_mint(struct xt_option_call *cb)
 {
 	const struct xt_option_entry *entry = cb->entry;
-	const char *arg = cb->arg;
+	const char *arg;
 	size_t esize = xtopt_esize_by_type(entry->type);
 	const uintmax_t lmax = xtopt_max_by_type(entry->type);
 	void *put = XTOPT_MKPTR(cb);
diff --git a/utils/nfnl_osf.c b/utils/nfnl_osf.c
index fad7f70024c56..0ea33fce960fe 100644
--- a/utils/nfnl_osf.c
+++ b/utils/nfnl_osf.c
@@ -157,7 +157,6 @@ static void xt_osf_parse_opt(struct xt_osf_opt *opt, __u16 *optnum, char *obuf,
 	i = 0;
 	while (ptr != NULL && i < olen && *ptr != 0) {
 		val = 0;
-		op = 0;
 		wc = OSF_WSS_PLAIN;
 		switch (obuf[i]) {
 		case 'N':
@@ -344,7 +343,7 @@ static int osf_load_line(char *buffer, int len, int del)
 	pend = xt_osf_strchr(pbeg, OSFPDEL);
 	if (pend) {
 		*pend = '\0';
-		cnt = snprintf(obuf, sizeof(obuf), "%s,", pbeg);
+		snprintf(obuf, sizeof(obuf), "%s,", pbeg);
 		pbeg = pend + 1;
 	}
 
@@ -352,25 +351,23 @@ static int osf_load_line(char *buffer, int len, int del)
 	if (pend) {
 		*pend = '\0';
 		if (pbeg[0] == '@' || pbeg[0] == '*')
-			cnt = snprintf(f.genre, sizeof(f.genre), "%s", pbeg + 1);
+			snprintf(f.genre, sizeof(f.genre), "%s", pbeg + 1);
 		else
-			cnt = snprintf(f.genre, sizeof(f.genre), "%s", pbeg);
+			snprintf(f.genre, sizeof(f.genre), "%s", pbeg);
 		pbeg = pend + 1;
 	}
 
 	pend = xt_osf_strchr(pbeg, OSFPDEL);
 	if (pend) {
 		*pend = '\0';
-		cnt = snprintf(f.version, sizeof(f.version), "%s", pbeg);
+		snprintf(f.version, sizeof(f.version), "%s", pbeg);
 		pbeg = pend + 1;
 	}
 
 	pend = xt_osf_strchr(pbeg, OSFPDEL);
 	if (pend) {
 		*pend = '\0';
-		cnt =
-		    snprintf(f.subtype, sizeof(f.subtype), "%s", pbeg);
-		pbeg = pend + 1;
+		snprintf(f.subtype, sizeof(f.subtype), "%s", pbeg);
 	}
 
 	xt_osf_parse_opt(f.opt, &f.opt_num, obuf, sizeof(obuf));
-- 
2.18.0




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux