summaryrefslogtreecommitdiffstats
path: root/tc
diff options
context:
space:
mode:
authorMaciej Żenczykowski <maze@google.com>2015-06-25 02:03:02 -0700
committerStephen Hemminger <shemming@brocade.com>2015-06-25 08:52:06 -0400
commit0bbca0422f9779cc4eeaf70aa01dcad10d6ab076 (patch)
treeed616cd428fd532e47e3278578a8ff5250c698d7 /tc
parent45b01c46d420ed790f7733763060af1725735c05 (diff)
iproute2: tc/m_pedit.c - remove dead code
The initializers are simply not needed. These if-blocks are outright dead code, because '0 > unsigned' is always false, so only else clause triggers and regardless of which clause triggers it only updates 'ind' which is later unconditionally written to before being used anyway. Otherwise we get errors from clang: m_pedit.c:166:8: error: comparison of 0 > unsigned expression is always false [-Werror,-Wtautological-compare] if (0 > tkey->off) { ~ ^ ~~~~~~~~~ m_pedit.c:209:8: error: comparison of 0 > unsigned expression is always false [-Werror,-Wtautological-compare] if (0 > tkey->off) { ~ ^ ~~~~~~~~~ 2 errors generated. Change-Id: I3c9e9092915088fc56f992e5df736851541a4458
Diffstat (limited to 'tc')
-rw-r--r--tc/m_pedit.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/tc/m_pedit.c b/tc/m_pedit.c
index dfe9b2eb..4fdd189d 100644
--- a/tc/m_pedit.c
+++ b/tc/m_pedit.c
@@ -160,17 +160,9 @@ pack_key32(__u32 retain,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey)
int
pack_key16(__u32 retain,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey)
{
- int ind = 0, stride = 0;
+ int ind, stride;
__u32 m[4] = {0xFFFF0000,0xFF0000FF,0x0000FFFF};
- if (0 > tkey->off) {
- ind = tkey->off + 1;
- if (0 > ind)
- ind = -1*ind;
- } else {
- ind = tkey->off;
- }
-
if (tkey->val > 0xFFFF || tkey->mask > 0xFFFF) {
fprintf(stderr, "pack_key16 bad value\n");
return -1;
@@ -178,18 +170,16 @@ pack_key16(__u32 retain,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey)
ind = tkey->off & 3;
- if (0 > ind || 2 < ind) {
+ if (ind == 3) {
fprintf(stderr, "pack_key16 bad index value %d\n",ind);
return -1;
}
stride = 8 * ind;
tkey->val = htons(tkey->val);
- if (stride > 0) {
- tkey->val <<= stride;
- tkey->mask <<= stride;
- retain <<= stride;
- }
+ tkey->val <<= stride;
+ tkey->mask <<= stride;
+ retain <<= stride;
tkey->mask = retain|m[ind];
tkey->off &= ~3;
@@ -203,28 +193,22 @@ pack_key16(__u32 retain,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey)
int
pack_key8(__u32 retain,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey)
{
- int ind = 0, stride = 0;
+ int ind, stride;
__u32 m[4] = {0xFFFFFF00,0xFFFF00FF,0xFF00FFFF,0x00FFFFFF};
- if (0 > tkey->off) {
- ind = tkey->off + 1;
- if (0 > ind)
- ind = -1*ind;
- } else {
- ind = tkey->off;
- }
-
if (tkey->val > 0xFF || tkey->mask > 0xFF) {
fprintf(stderr, "pack_key8 bad value (val %x mask %x\n", tkey->val, tkey->mask);
return -1;
}
ind = tkey->off & 3;
+
stride = 8 * ind;
tkey->val <<= stride;
tkey->mask <<= stride;
retain <<= stride;
tkey->mask = retain|m[ind];
+
tkey->off &= ~3;
if (pedit_debug)