ipv4: coding style: comparison for inequality with NULL
[firefly-linux-kernel-4.4.55.git] / net / ipv4 / ip_output.c
index a7aea2048a0d7a624ceb79923d25e9750ec6fa9a..26f6f7956168a795e1c465a65e89939c5b7431d6 100644 (file)
@@ -148,7 +148,7 @@ int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
        iph->daddr    = (opt && opt->opt.srr ? opt->opt.faddr : daddr);
        iph->saddr    = saddr;
        iph->protocol = sk->sk_protocol;
-       ip_select_ident(skb, sk);
+       ip_select_ident(sock_net(sk), skb, sk);
 
        if (opt && opt->opt.optlen) {
                iph->ihl += opt->opt.optlen>>2;
@@ -182,7 +182,7 @@ static inline int ip_finish_output2(struct sk_buff *skb)
                struct sk_buff *skb2;
 
                skb2 = skb_realloc_headroom(skb, LL_RESERVED_SPACE(dev));
-               if (skb2 == NULL) {
+               if (!skb2) {
                        kfree_skb(skb);
                        return -ENOMEM;
                }
@@ -257,7 +257,7 @@ static int ip_finish_output(struct sk_buff *skb)
 {
 #if defined(CONFIG_NETFILTER) && defined(CONFIG_XFRM)
        /* Policy lookup after SNAT yielded a new policy */
-       if (skb_dst(skb)->xfrm != NULL) {
+       if (skb_dst(skb)->xfrm) {
                IPCB(skb)->flags |= IPSKB_REROUTED;
                return dst_output(skb);
        }
@@ -376,12 +376,12 @@ int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)
        inet_opt = rcu_dereference(inet->inet_opt);
        fl4 = &fl->u.ip4;
        rt = skb_rtable(skb);
-       if (rt != NULL)
+       if (rt)
                goto packet_routed;
 
        /* Make sure we can route this packet. */
        rt = (struct rtable *)__sk_dst_check(sk, 0);
-       if (rt == NULL) {
+       if (!rt) {
                __be32 daddr;
 
                /* Use correct destination address if we have options. */
@@ -430,7 +430,8 @@ packet_routed:
                ip_options_build(skb, &inet_opt->opt, inet->inet_daddr, rt, 0);
        }
 
-       ip_select_ident_segs(skb, sk, skb_shinfo(skb)->gso_segs ?: 1);
+       ip_select_ident_segs(sock_net(sk), skb, sk,
+                            skb_shinfo(skb)->gso_segs ?: 1);
 
        /* TODO : should we use skb->sk here instead of sk ? */
        skb->priority = sk->sk_priority;
@@ -586,7 +587,7 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
                                        ip_options_fragment(frag);
                                offset += skb->len - hlen;
                                iph->frag_off = htons(offset>>3);
-                               if (frag->next != NULL)
+                               if (frag->next)
                                        iph->frag_off |= htons(IP_MF);
                                /* Ready, complete checksum */
                                ip_send_check(iph);
@@ -636,10 +637,7 @@ slow_path:
        left = skb->len - hlen;         /* Space per frame */
        ptr = hlen;             /* Where to start from */
 
-       /* for bridged IP traffic encapsulated inside f.e. a vlan header,
-        * we need to make room for the encapsulating header
-        */
-       ll_rs = LL_RESERVED_SPACE_EXTRA(rt->dst.dev, nf_bridge_pad(skb));
+       ll_rs = LL_RESERVED_SPACE(rt->dst.dev);
 
        /*
         *      Fragment the datagram.
@@ -792,12 +790,13 @@ static inline int ip_ufo_append_data(struct sock *sk,
         * device, so create one single skb packet containing complete
         * udp datagram
         */
-       if ((skb = skb_peek_tail(queue)) == NULL) {
+       skb = skb_peek_tail(queue);
+       if (!skb) {
                skb = sock_alloc_send_skb(sk,
                        hh_len + fragheaderlen + transhdrlen + 20,
                        (flags & MSG_DONTWAIT), &err);
 
-               if (skb == NULL)
+               if (!skb)
                        return err;
 
                /* reserve space for Hardware header */
@@ -963,10 +962,10 @@ alloc_new_skb:
                                        skb = sock_wmalloc(sk,
                                                           alloclen + hh_len + 15, 1,
                                                           sk->sk_allocation);
-                               if (unlikely(skb == NULL))
+                               if (unlikely(!skb))
                                        err = -ENOBUFS;
                        }
-                       if (skb == NULL)
+                       if (!skb)
                                goto error;
 
                        /*
@@ -1090,10 +1089,10 @@ static int ip_setup_cork(struct sock *sk, struct inet_cork *cork,
         */
        opt = ipc->opt;
        if (opt) {
-               if (cork->opt == NULL) {
+               if (!cork->opt) {
                        cork->opt = kmalloc(sizeof(struct ip_options) + 40,
                                            sk->sk_allocation);
-                       if (unlikely(cork->opt == NULL))
+                       if (unlikely(!cork->opt))
                                return -ENOBUFS;
                }
                memcpy(cork->opt, &opt->opt, sizeof(struct ip_options) + opt->opt.optlen);
@@ -1200,7 +1199,8 @@ ssize_t   ip_append_page(struct sock *sk, struct flowi4 *fl4, struct page *page,
                return -EMSGSIZE;
        }
 
-       if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL)
+       skb = skb_peek_tail(&sk->sk_write_queue);
+       if (!skb)
                return -EINVAL;
 
        cork->length += size;
@@ -1331,7 +1331,8 @@ struct sk_buff *__ip_make_skb(struct sock *sk,
        __be16 df = 0;
        __u8 ttl;
 
-       if ((skb = __skb_dequeue(queue)) == NULL)
+       skb = __skb_dequeue(queue);
+       if (!skb)
                goto out;
        tail_skb = &(skb_shinfo(skb)->frag_list);
 
@@ -1382,7 +1383,7 @@ struct sk_buff *__ip_make_skb(struct sock *sk,
        iph->ttl = ttl;
        iph->protocol = sk->sk_protocol;
        ip_copy_addrs(iph, fl4);
-       ip_select_ident(skb, sk);
+       ip_select_ident(net, skb, sk);
 
        if (opt) {
                iph->ihl += opt->optlen>>2;