From 7e50ebabbf9c3a5eeb9511d9f32c6104b56da5cd Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Wed, 19 Sep 2018 15:17:04 +0200 Subject: Fix a few cases of pointless assignments This gets rid of a number of assignments which are either redundant or not used afterwards. Signed-off-by: Phil Sutter Signed-off-by: Florian Westphal --- 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 ++-- 7 files changed, 8 insertions(+), 14 deletions(-) (limited to 'iptables') diff --git a/iptables/ip6tables-restore.c b/iptables/ip6tables-restore.c index 2bb303ac..3706b981 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 5c211d07..daee5fd9 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 788a67c6..07300efc 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 032c3788..b81f41ab 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 fb37b56e..07d61776 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 6aa1cba3..84d554e9 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 -L ) */ 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 9d15593f..d9faa4d0 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", -- cgit v1.2.3