]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tc/m_gact: Drop dead code
authorPhil Sutter <phil@nwl.cc>
Thu, 17 Aug 2017 17:09:31 +0000 (19:09 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 22 Aug 2017 00:12:21 +0000 (17:12 -0700)
The use of 'ok' variable in parse_gact() is ineffective: The second
conditional increments it either if *argv is 'gact' or if
parse_action_control() doesn't fail (in which case exit() is called).
So this is effectively an unconditional increment and since no decrement
happens anywhere, all remaining checks for 'ok != 0' can be dropped.

Signed-off-by: Phil Sutter <phil@nwl.cc>
tc/m_gact.c

index 1a2583372c34ea30bb074668c025b89a45f1665c..df143c9e0953eb5afa16ca98bca8e7aba318d0f1 100644 (file)
@@ -76,7 +76,6 @@ parse_gact(struct action_util *a, int *argc_p, char ***argv_p,
 {
        int argc = *argc_p;
        char **argv = *argv_p;
-       int ok = 0;
        struct tc_gact p = { 0 };
 #ifdef CONFIG_GACT_PROB
        int rd = 0;
@@ -89,17 +88,14 @@ parse_gact(struct action_util *a, int *argc_p, char ***argv_p,
 
 
        if (matches(*argv, "gact") == 0) {
-               ok++;
                argc--;
                argv++;
-       } else {
-               if (parse_action_control(&argc, &argv, &p.action, false) == -1)
-                       usage();
-               ok++;
+       } else if (parse_action_control(&argc, &argv, &p.action, false) == -1) {
+               usage();        /* does not return */
        }
 
 #ifdef CONFIG_GACT_PROB
-       if (ok && argc > 0) {
+       if (argc > 0) {
                if (matches(*argv, "random") == 0) {
                        rd = 1;
                        NEXT_ARG();
@@ -142,15 +138,11 @@ parse_gact(struct action_util *a, int *argc_p, char ***argv_p,
                        }
                        argc--;
                        argv++;
-                       ok++;
                } else if (matches(*argv, "help") == 0) {
                                usage();
                }
        }
 
-       if (!ok)
-               return -1;
-
        tail = NLMSG_TAIL(n);
        addattr_l(n, MAX_MSG, tca_id, NULL, 0);
        addattr_l(n, MAX_MSG, TCA_GACT_PARMS, &p, sizeof(p));