ipv6: coding style improvements (remove assignment in if statements)
authorIan Morris <ipm@chirality.org.uk>
Sun, 23 Nov 2014 21:28:43 +0000 (21:28 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 24 Nov 2014 02:00:56 +0000 (21:00 -0500)
This change has no functional impact and simply addresses some coding
style issues detected by checkpatch. Specifically this change
adjusts "if" statements which also include the assignment of a
variable.

No changes to the resultant object files result as determined by objdiff.

Signed-off-by: Ian Morris <ipm@chirality.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
13 files changed:
net/ipv6/addrconf.c
net/ipv6/ah6.c
net/ipv6/esp6.c
net/ipv6/icmp.c
net/ipv6/ip6_flowlabel.c
net/ipv6/ip6_input.c
net/ipv6/ip6_output.c
net/ipv6/ip6_tunnel.c
net/ipv6/ip6_vti.c
net/ipv6/ndisc.c
net/ipv6/reassembly.c
net/ipv6/sit.c
net/ipv6/udp.c

index 251fcb48b216054298b93c558c56402d804841b2..9eac3a7fefa39b5f57086c74934dd5e8867020d3 100644 (file)
@@ -2543,7 +2543,8 @@ static int inet6_addr_del(struct net *net, int ifindex, u32 ifa_flags,
        if (!dev)
                return -ENODEV;
 
-       if ((idev = __in6_dev_get(dev)) == NULL)
+       idev = __in6_dev_get(dev);
+       if (idev == NULL)
                return -ENXIO;
 
        read_lock_bh(&idev->lock);
@@ -2690,7 +2691,8 @@ static void init_loopback(struct net_device *dev)
 
        ASSERT_RTNL();
 
-       if ((idev = ipv6_find_idev(dev)) == NULL) {
+       idev = ipv6_find_idev(dev);
+       if (idev == NULL) {
                pr_debug("%s: add_dev failed\n", __func__);
                return;
        }
@@ -2813,7 +2815,8 @@ static void addrconf_sit_config(struct net_device *dev)
         * our v4 addrs in the tunnel
         */
 
-       if ((idev = ipv6_find_idev(dev)) == NULL) {
+       idev = ipv6_find_idev(dev);
+       if (idev == NULL) {
                pr_debug("%s: add_dev failed\n", __func__);
                return;
        }
@@ -2837,7 +2840,8 @@ static void addrconf_gre_config(struct net_device *dev)
 
        ASSERT_RTNL();
 
-       if ((idev = ipv6_find_idev(dev)) == NULL) {
+       idev = ipv6_find_idev(dev);
+       if (idev == NULL) {
                pr_debug("%s: add_dev failed\n", __func__);
                return;
        }
index 8ab1989198f61ee986e140a0f001f3a09a2c5495..a6727add26240e9980ce8da620a6e5bf5cddaf8d 100644 (file)
@@ -353,7 +353,8 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb)
        ahp = x->data;
        ahash = ahp->ahash;
 
-       if ((err = skb_cow_data(skb, 0, &trailer)) < 0)
+       err = skb_cow_data(skb, 0, &trailer);
+       if (err < 0)
                goto out;
        nfrags = err;
 
@@ -559,8 +560,8 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
        if (!pskb_may_pull(skb, ah_hlen))
                goto out;
 
-
-       if ((err = skb_cow_data(skb, 0, &trailer)) < 0)
+       err = skb_cow_data(skb, 0, &trailer);
+       if (err < 0)
                goto out;
        nfrags = err;
 
index d2c2d749b6db4ce2615f2ae82e9becb4068320be..e48f2c7c5c596b0a364636b7ed6d6e693e9e925f 100644 (file)
@@ -345,7 +345,8 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
                goto out;
        }
 
-       if ((nfrags = skb_cow_data(skb, 0, &trailer)) < 0) {
+       nfrags = skb_cow_data(skb, 0, &trailer);
+       if (nfrags < 0) {
                ret = -EINVAL;
                goto out;
        }
index 39b3ff97a5045c38e13fd2b22ed60b818e6d8855..d674152b6ede5d6134f1a89cb8ebaa6a81308c73 100644 (file)
@@ -243,7 +243,8 @@ int icmpv6_push_pending_frames(struct sock *sk, struct flowi6 *fl6,
        struct icmp6hdr *icmp6h;
        int err = 0;
 
-       if ((skb = skb_peek(&sk->sk_write_queue)) == NULL)
+       skb = skb_peek(&sk->sk_write_queue);
+       if (skb == NULL)
                goto out;
 
        icmp6h = icmp6_hdr(skb);
index 7221021b2d978ee2316d28c35776fee6bbd9549b..2f780cba6e1240b06e4fc64eb20c949ab3646558 100644 (file)
@@ -654,7 +654,11 @@ release:
                        goto done;
 
                err = -ENOMEM;
-               if (sfl1 == NULL || (err = mem_check(sk)) != 0)
+               if (sfl1 == NULL)
+                       goto done;
+
+               err = mem_check(sk);
+               if (err != 0)
                        goto done;
 
                fl1 = fl_intern(net, fl, freq.flr_label);
index a3084ab5df6cd1b343af6d725975082f5c4b6eb6..aacdcb4dc7624117561ce9720fa4734ed06ce5a0 100644 (file)
@@ -220,7 +220,8 @@ resubmit:
        nexthdr = skb_network_header(skb)[nhoff];
 
        raw = raw6_local_deliver(skb, nexthdr);
-       if ((ipprot = rcu_dereference(inet6_protos[nexthdr])) != NULL) {
+       ipprot = rcu_dereference(inet6_protos[nexthdr]);
+       if (ipprot != NULL) {
                int ret;
 
                if (ipprot->flags & INET6_PROTO_FINAL) {
index 916d2a166a9b7b02a679d8e8ddafaa45b4878932..ce69a12ae48c29276871dacb30eebea086b291a3 100644 (file)
@@ -898,7 +898,8 @@ static int ip6_dst_lookup_tail(struct sock *sk,
        if (*dst == NULL)
                *dst = ip6_route_output(net, sk, fl6);
 
-       if ((err = (*dst)->error))
+       err = (*dst)->error;
+       if (err)
                goto out_err_release;
 
        if (ipv6_addr_any(&fl6->saddr)) {
@@ -946,7 +947,8 @@ static int ip6_dst_lookup_tail(struct sock *sk,
                        memcpy(&fl_gw6, fl6, sizeof(struct flowi6));
                        memset(&fl_gw6.daddr, 0, sizeof(struct in6_addr));
                        *dst = ip6_route_output(net, sk, &fl_gw6);
-                       if ((err = (*dst)->error))
+                       err = (*dst)->error;
+                       if (err)
                                goto out_err_release;
                }
        }
@@ -1054,7 +1056,8 @@ static inline int ip6_ufo_append_data(struct sock *sk,
         * device, so create one single skb packet containing complete
         * udp datagram
         */
-       if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) {
+       skb = skb_peek_tail(&sk->sk_write_queue);
+       if (skb == NULL) {
                skb = sock_alloc_send_skb(sk,
                        hh_len + fragheaderlen + transhdrlen + 20,
                        (flags & MSG_DONTWAIT), &err);
@@ -1534,7 +1537,8 @@ int ip6_push_pending_frames(struct sock *sk)
        unsigned char proto = fl6->flowi6_proto;
        int err = 0;
 
-       if ((skb = __skb_dequeue(&sk->sk_write_queue)) == NULL)
+       skb = __skb_dequeue(&sk->sk_write_queue);
+       if (skb == NULL)
                goto out;
        tail_skb = &(skb_shinfo(skb)->frag_list);
 
index e2b6cfba873c082acb513a75239b1d6b0118b6d3..92b3da571980670e4f343a278eec49521057be1e 100644 (file)
@@ -501,8 +501,8 @@ ip6_tnl_err(struct sk_buff *skb, __u8 ipproto, struct inet6_skb_parm *opt,
           processing of the error. */
 
        rcu_read_lock();
-       if ((t = ip6_tnl_lookup(dev_net(skb->dev), &ipv6h->daddr,
-                                       &ipv6h->saddr)) == NULL)
+       t = ip6_tnl_lookup(dev_net(skb->dev), &ipv6h->daddr, &ipv6h->saddr);
+       if (t == NULL)
                goto out;
 
        tproto = ACCESS_ONCE(t->parms.proto);
@@ -550,7 +550,8 @@ ip6_tnl_err(struct sk_buff *skb, __u8 ipproto, struct inet6_skb_parm *opt,
                        mtu = IPV6_MIN_MTU;
                t->dev->mtu = mtu;
 
-               if ((len = sizeof(*ipv6h) + ntohs(ipv6h->payload_len)) > mtu) {
+               len = sizeof(*ipv6h) + ntohs(ipv6h->payload_len);
+               if (len > mtu) {
                        rel_type = ICMPV6_PKT_TOOBIG;
                        rel_code = 0;
                        rel_info = mtu;
@@ -811,9 +812,8 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol,
        int err;
 
        rcu_read_lock();
-
-       if ((t = ip6_tnl_lookup(dev_net(skb->dev), &ipv6h->saddr,
-                                       &ipv6h->daddr)) != NULL) {
+       t = ip6_tnl_lookup(dev_net(skb->dev), &ipv6h->saddr, &ipv6h->daddr);
+       if (t != NULL) {
                struct pcpu_sw_netstats *tstats;
 
                tproto = ACCESS_ONCE(t->parms.proto);
@@ -1069,7 +1069,8 @@ static int ip6_tnl_xmit2(struct sk_buff *skb,
            (skb_cloned(skb) && !skb_clone_writable(skb, 0))) {
                struct sk_buff *new_skb;
 
-               if (!(new_skb = skb_realloc_headroom(skb, max_headroom)))
+               new_skb = skb_realloc_headroom(skb, max_headroom);
+               if (!new_skb)
                        goto tx_err_dst_release;
 
                if (skb->sk)
index ec84d03491c72cd2ab75822273cb3d955da2d10d..83082168b0565cae0b758a649940a59a7f3ac6b6 100644 (file)
@@ -287,8 +287,8 @@ static int vti6_rcv(struct sk_buff *skb)
        const struct ipv6hdr *ipv6h = ipv6_hdr(skb);
 
        rcu_read_lock();
-       if ((t = vti6_tnl_lookup(dev_net(skb->dev), &ipv6h->saddr,
-                                &ipv6h->daddr)) != NULL) {
+       t = vti6_tnl_lookup(dev_net(skb->dev), &ipv6h->saddr, &ipv6h->daddr);
+       if (t != NULL) {
                if (t->parms.proto != IPPROTO_IPV6 && t->parms.proto != 0) {
                        rcu_read_unlock();
                        goto discard;
index 2c9f6bf57325bdcf180bb77b1df5891a5e93181d..682866777d5383dabaf6e3ae2f6f2deef261f557 100644 (file)
@@ -162,7 +162,8 @@ static void ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data)
        memcpy(opt+2, data, data_len);
        data_len += 2;
        opt += data_len;
-       if ((space -= data_len) > 0)
+       space -= data_len;
+       if (space > 0)
                memset(opt, 0, space);
 }
 
@@ -656,8 +657,8 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
 
        if (skb && ipv6_chk_addr(dev_net(dev), &ipv6_hdr(skb)->saddr, dev, 1))
                saddr = &ipv6_hdr(skb)->saddr;
-
-       if ((probes -= NEIGH_VAR(neigh->parms, UCAST_PROBES)) < 0) {
+       probes -= NEIGH_VAR(neigh->parms, UCAST_PROBES);
+       if (probes < 0) {
                if (!(neigh->nud_state & NUD_VALID)) {
                        ND_PRINTK(1, dbg,
                                  "%s: trying to ucast probe in NUD_INVALID: %pI6\n",
index 51ab096ae5746261cf320741b455188889f87038..d7d70e69973b7455fbf2b5cb88a09d428f9c45ea 100644 (file)
@@ -429,7 +429,8 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
                struct sk_buff *clone;
                int i, plen = 0;
 
-               if ((clone = alloc_skb(0, GFP_ATOMIC)) == NULL)
+               clone = alloc_skb(0, GFP_ATOMIC);
+               if (clone == NULL)
                        goto out_oom;
                clone->next = head->next;
                head->next = clone;
index 660496de61258ffaecce9e4ae2afdc87f956db88..213546bd6d5de5eeccfabe45c6dd4d575b475266 100644 (file)
@@ -1241,7 +1241,8 @@ ipip6_tunnel_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
                        if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p)))
                                goto done;
                        err = -ENOENT;
-                       if ((t = ipip6_tunnel_locate(net, &p, 0)) == NULL)
+                       t = ipip6_tunnel_locate(net, &p, 0);
+                       if (t == NULL)
                                goto done;
                        err = -EPERM;
                        if (t == netdev_priv(sitn->fb_tunnel_dev))
@@ -1836,8 +1837,8 @@ static int __net_init sit_init_net(struct net *net)
                goto err_dev_free;
 
        ipip6_tunnel_clone_6rd(sitn->fb_tunnel_dev, sitn);
-
-       if ((err = register_netdev(sitn->fb_tunnel_dev)))
+       err = register_netdev(sitn->fb_tunnel_dev);
+       if (err)
                goto err_reg_dev;
 
        t = netdev_priv(sitn->fb_tunnel_dev);
index 0ba3de4f236877fb1f3410e74e9fcf551f945512..dbc0b042bdd6b09eeb3adf5fd81b8bb8bf727515 100644 (file)
@@ -357,7 +357,8 @@ static struct sock *__udp6_lib_lookup_skb(struct sk_buff *skb,
        struct sock *sk;
        const struct ipv6hdr *iph = ipv6_hdr(skb);
 
-       if (unlikely(sk = skb_steal_sock(skb)))
+       sk = skb_steal_sock(skb);
+       if (unlikely(sk))
                return sk;
        return __udp6_lib_lookup(dev_net(skb_dst(skb)->dev), &iph->saddr, sport,
                                 &iph->daddr, dport, inet6_iif(skb),
@@ -1026,7 +1027,8 @@ static int udp_v6_push_pending_frames(struct sock *sk)
        fl6 = &inet->cork.fl.u.ip6;
 
        /* Grab the skbuff where UDP header space exists. */
-       if ((skb = skb_peek(&sk->sk_write_queue)) == NULL)
+       skb = skb_peek(&sk->sk_write_queue);
+       if (skb == NULL)
                goto out;
 
        /*