lwtunnel: change prototype of lwtunnel_state_get()
authorNicolas Dichtel <nicolas.dichtel@6wind.com>
Fri, 24 Jul 2015 10:28:36 +0000 (12:28 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 27 Jul 2015 08:02:49 +0000 (01:02 -0700)
It saves some lines and simplify a bit the code when the state is returning
by this function. It's also useful to handle a NULL entry.

To avoid too long lines, I've also renamed lwtunnel_state_get() and
lwtunnel_state_put() to lwtstate_get() and lwtstate_put().

CC: Thomas Graf <tgraf@suug.ch>
CC: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/lwtunnel.h
net/ipv4/fib_semantics.c
net/ipv4/route.c
net/ipv6/ip6_fib.c
net/ipv6/route.c

index 918e03c..b020390 100644 (file)
@@ -35,12 +35,16 @@ extern const struct lwtunnel_encap_ops __rcu *
                lwtun_encaps[LWTUNNEL_ENCAP_MAX+1];
 
 #ifdef CONFIG_LWTUNNEL
-static inline void lwtunnel_state_get(struct lwtunnel_state *lws)
+static inline struct lwtunnel_state *
+lwtstate_get(struct lwtunnel_state *lws)
 {
-       atomic_inc(&lws->refcnt);
+       if (lws)
+               atomic_inc(&lws->refcnt);
+
+       return lws;
 }
 
-static inline void lwtunnel_state_put(struct lwtunnel_state *lws)
+static inline void lwtstate_put(struct lwtunnel_state *lws)
 {
        if (!lws)
                return;
@@ -74,11 +78,13 @@ int lwtunnel_output6(struct sock *sk, struct sk_buff *skb);
 
 #else
 
-static inline void lwtunnel_state_get(struct lwtunnel_state *lws)
+static inline struct lwtunnel_state *
+lwtstate_get(struct lwtunnel_state *lws)
 {
+       return lws;
 }
 
-static inline void lwtunnel_state_put(struct lwtunnel_state *lws)
+static inline void lwtstate_put(struct lwtunnel_state *lws)
 {
 }
 
Simple merge
Simple merge
Simple merge
Simple merge