]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
nft: Eliminate dead code in __nft_rule_list
authorPhil Sutter <phil@nwl.cc>
Thu, 7 Feb 2019 08:20:10 +0000 (09:20 +0100)
committerFlorian Westphal <fw@strlen.de>
Mon, 11 Feb 2019 16:13:09 +0000 (17:13 +0100)
If passed a rulenum > 0, the function uses nftnl_rule_lookup_byindex()
and returns early. Negative rulenum values are not supposed to happen,
so the remaining code which iterates over the full list of rules does
not need to respect rulenum anymore.

Fixes: 039b048965210 ("nft: Make use of nftnl_rule_lookup_byindex()")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
iptables/nft.c

index 2d527358cc7f2efa10323fc9add91c82acd063a8..d708fb6176b88063b900608b7ee1de6c5c02a62d 100644 (file)
@@ -2331,18 +2331,7 @@ __nft_rule_list(struct nft_handle *h, struct nftnl_chain *c,
 
        r = nftnl_rule_iter_next(iter);
        while (r != NULL) {
-               rule_ctr++;
-
-               if (rulenum > 0 && rule_ctr != rulenum) {
-                       /* List by rule number case */
-                       goto next;
-               }
-
-               cb(r, rule_ctr, format);
-               if (rulenum > 0)
-                       break;
-
-next:
+               cb(r, ++rule_ctr, format);
                r = nftnl_rule_iter_next(iter);
        }