tcp/dccp: Move initialisation of refcounted into if block.
Subsystems (2)
PATCH v2 1/1 tcp/dccp: Move initialisation of refcounted into if block.
The refcounted seems to be initialised at most three times, but the complier can optimize that and the refcounted is initialised only at once.
- __inet_lookup_skb() sets it true.
- skb_steal_sock() is false and __inet_lookup() sets it true.
- __inet_lookup_established() is false and __inet_lookup() sets it false.
The code is bit confusing, so this patch makes it more readable so that no one doubt about the complier optimization.
--- include/net/inet6_hashtables.h | 11 +++++++---- include/net/inet_hashtables.h | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-)
include/net/inet6_hashtables.h +7 -4
@@ -70,9 +70,11 @@ static inline struct sock *__inet6_lookup(struct net *net,struct sock *sk =__inet6_lookup_established (net, hashinfo, saddr, sport, daddr, hnum, dif, sdif); - *refcounted = true; -if (sk) +if (sk) { + *refcounted = true;return sk; + } + *refcounted = false;return inet6_lookup_listener (net, hashinfo, skb, doff, saddr, sport, daddr, hnum, dif, sdif);
@@ -87,9 +89,10 @@ static inline struct sock *__inet6_lookup_skb(struct inet_hashinfo *hashinfo, {struct sock *sk =skb_steal_sock (skb); - *refcounted = true; -if (sk) +if (sk) { + *refcounted = true;return sk; + } return __inet6_lookup(dev_net(skb_dst(skb)->dev), hashinfo, skb, doff, &ipv6_hdr(skb)->saddr, sport,
include/net/inet_hashtables.h +7 -4
@@ -345,9 +345,11 @@ static inline struct sock *__inet_lookup(struct net *net, sk =__inet_lookup_established (net, hashinfo, saddr, sport, daddr, hnum, dif, sdif); - *refcounted = true; -if (sk) +if (sk) { + *refcounted = true;return sk; + } + *refcounted = false;return __inet_lookup_listener (net, hashinfo, skb, doff, saddr, sport, daddr, hnum, dif, sdif);
@@ -382,9 +384,10 @@ static inline struct sock *__inet_lookup_skb(struct inet_hashinfo *hashinfo,struct sock *sk =skb_steal_sock (skb);const struct iphdr *iph =ip_hdr (skb); - *refcounted = true; -if (sk) +if (sk) { + *refcounted = true;return sk; + } return __inet_lookup(dev_net(skb_dst(skb)->dev), hashinfo, skb, doff, iph->saddr, sport,
Signature · 1 line
2.17.2 (Apple Git-113)
David Miller
maintainerFrom: Kuniyuki Iwashima <[email protected]>
Date: Tue, 24 Mar 2020 20:33:31 +0900
Quoted 11 lines
The refcounted seems to be initialised at most three times, but the complier can optimize that and the refcounted is initialised only at once.
-
__inet_lookup_skb()sets it true.
-skb_steal_sock()is false and__inet_lookup()sets it true.
-__inet_lookup_established()is false and__inet_lookup()sets it false.The code is bit confusing, so this patch makes it more readable so that no one doubt about the complier optimization.
Signed-off-by Kuniyuki Iwashima <[email protected]>
I don't think this improves the code readability nor code generation, it's just noise changes and will make backporting more difficult.
I'm not applying this sorry.
In the future, I am going to apply a large threshold as to whether changes like this are reasonable and appropriate. Please keep that in mind for your submissions.
Thank you.