diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2016-11-19 04:08:08 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-11-20 06:11:25 +0300 |
commit | c72d8cdaa5dbd3baf918046ee5149ab69330923e (patch) | |
tree | bb708dd87b0244c6aaab7ab2a6499c1ad9706d90 /net/ipv6 | |
parent | 32d84cdcfde00f28f6133f0e2b015c86f2466fb1 (diff) | |
download | linux-c72d8cdaa5dbd3baf918046ee5149ab69330923e.tar.xz |
net: fix bogus cast in skb_pagelen() and use unsigned variables
1) cast to "int" is unnecessary:
u8 will be promoted to int before decrementing,
small positive numbers fit into "int", so their values won't be changed
during promotion.
Once everything is int including loop counters, signedness doesn't
matter: 32-bit operations will stay 32-bit operations.
But! Someone tried to make this loop smart by making everything of
the same type apparently in an attempt to optimise it.
Do the optimization, just differently.
Do the cast where it matters. :^)
2) frag size is unsigned entity and sum of fragments sizes is also
unsigned.
Make everything unsigned, leave no MOVSX instruction behind.
add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-4 (-4)
function old new delta
skb_cow_data 835 834 -1
ip_do_fragment 2549 2548 -1
ip6_fragment 3130 3128 -2
Total: Before=154865032, After=154865028, chg -0.00%
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/ip6_output.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index b37054b1873d..312cbd0e5038 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -625,7 +625,7 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, hroom = LL_RESERVED_SPACE(rt->dst.dev); if (skb_has_frag_list(skb)) { - int first_len = skb_pagelen(skb); + unsigned int first_len = skb_pagelen(skb); struct sk_buff *frag2; if (first_len - hlen > mtu || |