From: Phil Sutter <phil@nwl.cc>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: netdev@vger.kernel.org
Subject: [iproute PATCH v2 7/7] tc/m_gact: Drop dead code
Date: Thu, 17 Aug 2017 19:09:31 +0200 [thread overview]
Message-ID: <20170817170931.24089-8-phil@nwl.cc> (raw)
In-Reply-To: <20170817170931.24089-1-phil@nwl.cc>
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 | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/tc/m_gact.c b/tc/m_gact.c
index 1a2583372c34e..df143c9e0953e 100644
--- a/tc/m_gact.c
+++ b/tc/m_gact.c
@@ -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));
--
2.13.1
next prev parent reply other threads:[~2017-08-17 17:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-17 17:09 [iproute PATCH v2 0/7] Covscan: Dead code elimination Phil Sutter
2017-08-17 17:09 ` [iproute PATCH v2 1/7] devlink: No need for this self-assignment Phil Sutter
2017-08-17 19:48 ` Jiri Pirko
2017-08-18 10:20 ` Phil Sutter
2017-08-21 9:02 ` Jiri Pirko
2017-08-17 17:09 ` [iproute PATCH v2 2/7] ipntable: No need to check and assign to parms_rta Phil Sutter
2017-08-17 17:09 ` [iproute PATCH v2 3/7] iproute: Fix for missing 'Oifs:' display Phil Sutter
2017-08-17 17:09 ` [iproute PATCH v2 4/7] lib/rt_names: Drop dead code in rtnl_rttable_n2a() Phil Sutter
2017-08-17 17:09 ` [iproute PATCH v2 5/7] ss: Skip useless check in parse_hostcond() Phil Sutter
2017-08-17 17:09 ` [iproute PATCH v2 6/7] ss: Drop useless assignment Phil Sutter
2017-08-17 17:09 ` Phil Sutter [this message]
2017-08-22 0:13 ` [iproute PATCH v2 0/7] Covscan: Dead code elimination Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170817170931.24089-8-phil@nwl.cc \
--to=phil@nwl.cc \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).