]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
Fix a few cases of pointless assignments
authorPhil Sutter <phil@nwl.cc>
Wed, 19 Sep 2018 13:17:04 +0000 (15:17 +0200)
committerFlorian Westphal <fw@strlen.de>
Mon, 24 Sep 2018 09:49:57 +0000 (11:49 +0200)
This gets rid of a number of assignments which are either redundant or
not used afterwards.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
iptables/ip6tables-restore.c
iptables/iptables-restore.c
iptables/iptables-xml.c
iptables/nft.c
iptables/xtables-eb-translate.c
iptables/xtables-eb.c
iptables/xtables-restore.c
libxtables/xtoptions.c
utils/nfnl_osf.c

index 2bb303ac755b64e86091aa1aaeab8dbd2f86cdda..3706b981a806a9ecd35930671ac2df1f2a036c26 100644 (file)
@@ -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",
index 5c211d07fa4532eea27e73df92f7cf381ed3b080..daee5fd99564a632fc0ea5ea79113098b587336b 100644 (file)
@@ -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",
index 788a67c608ec67111d407423cbf276a394f60414..07300efc25eb41bed296f472de1f46b3c6db5e9a 100644 (file)
@@ -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",
index 032c3788a20a74c5a9eee55f1d83ced2e45ce4ac..b81f41ab5350ba09e7cee7d65bef3433c3b49cda 100644 (file)
@@ -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)
index fb37b56ec23ce20766172f87bc86ebb7902cd956..07d6177627df297047eeaff9fa08184ef002590e 100644 (file)
@@ -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);
index 6aa1cba3e5b9d4fe7562e37933a5659aff2d86b4..84d554e9b80e04449b97249b943fb24b94af28d5 100644 (file)
@@ -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);
index 9d15593f95eedb54dc1c2a54eb16a86ef66781b7..d9faa4d01ca4a0c59f3dbed9514a4e0265301c10 100644 (file)
@@ -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",
index 05887a05eab7144d84f2820615bf08cae8aee401..d329f2ff7979e590d1b9ac217c93b6616711bebc 100644 (file)
@@ -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);
index fad7f70024c5691430c5a1a6649c44f1351d4257..0ea33fce960fe89a6519752ef1d4b3c0cc7bf3ec 100644 (file)
@@ -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));