Skip to content

Commit e5d08d7

Browse files
lz7tq4davem330
authored andcommitted
ipv6: coding style improvements (remove assignment in if statements)
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 78e2045 commit e5d08d7

File tree

13 files changed

+55
-33
lines changed

13 files changed

+55
-33
lines changed

net/ipv6/addrconf.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2543,7 +2543,8 @@ static int inet6_addr_del(struct net *net, int ifindex, u32 ifa_flags,
25432543
if (!dev)
25442544
return -ENODEV;
25452545

2546-
if ((idev = __in6_dev_get(dev)) == NULL)
2546+
idev = __in6_dev_get(dev);
2547+
if (idev == NULL)
25472548
return -ENXIO;
25482549

25492550
read_lock_bh(&idev->lock);
@@ -2690,7 +2691,8 @@ static void init_loopback(struct net_device *dev)
26902691

26912692
ASSERT_RTNL();
26922693

2693-
if ((idev = ipv6_find_idev(dev)) == NULL) {
2694+
idev = ipv6_find_idev(dev);
2695+
if (idev == NULL) {
26942696
pr_debug("%s: add_dev failed\n", __func__);
26952697
return;
26962698
}
@@ -2813,7 +2815,8 @@ static void addrconf_sit_config(struct net_device *dev)
28132815
* our v4 addrs in the tunnel
28142816
*/
28152817

2816-
if ((idev = ipv6_find_idev(dev)) == NULL) {
2818+
idev = ipv6_find_idev(dev);
2819+
if (idev == NULL) {
28172820
pr_debug("%s: add_dev failed\n", __func__);
28182821
return;
28192822
}
@@ -2837,7 +2840,8 @@ static void addrconf_gre_config(struct net_device *dev)
28372840

28382841
ASSERT_RTNL();
28392842

2840-
if ((idev = ipv6_find_idev(dev)) == NULL) {
2843+
idev = ipv6_find_idev(dev);
2844+
if (idev == NULL) {
28412845
pr_debug("%s: add_dev failed\n", __func__);
28422846
return;
28432847
}

net/ipv6/ah6.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb)
353353
ahp = x->data;
354354
ahash = ahp->ahash;
355355

356-
if ((err = skb_cow_data(skb, 0, &trailer)) < 0)
356+
err = skb_cow_data(skb, 0, &trailer);
357+
if (err < 0)
357358
goto out;
358359
nfrags = err;
359360

@@ -559,8 +560,8 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
559560
if (!pskb_may_pull(skb, ah_hlen))
560561
goto out;
561562

562-
563-
if ((err = skb_cow_data(skb, 0, &trailer)) < 0)
563+
err = skb_cow_data(skb, 0, &trailer);
564+
if (err < 0)
564565
goto out;
565566
nfrags = err;
566567

net/ipv6/esp6.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
345345
goto out;
346346
}
347347

348-
if ((nfrags = skb_cow_data(skb, 0, &trailer)) < 0) {
348+
nfrags = skb_cow_data(skb, 0, &trailer);
349+
if (nfrags < 0) {
349350
ret = -EINVAL;
350351
goto out;
351352
}

net/ipv6/icmp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ int icmpv6_push_pending_frames(struct sock *sk, struct flowi6 *fl6,
243243
struct icmp6hdr *icmp6h;
244244
int err = 0;
245245

246-
if ((skb = skb_peek(&sk->sk_write_queue)) == NULL)
246+
skb = skb_peek(&sk->sk_write_queue);
247+
if (skb == NULL)
247248
goto out;
248249

249250
icmp6h = icmp6_hdr(skb);

net/ipv6/ip6_flowlabel.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,11 @@ int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen)
654654
goto done;
655655

656656
err = -ENOMEM;
657-
if (sfl1 == NULL || (err = mem_check(sk)) != 0)
657+
if (sfl1 == NULL)
658+
goto done;
659+
660+
err = mem_check(sk);
661+
if (err != 0)
658662
goto done;
659663

660664
fl1 = fl_intern(net, fl, freq.flr_label);

net/ipv6/ip6_input.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ static int ip6_input_finish(struct sk_buff *skb)
220220
nexthdr = skb_network_header(skb)[nhoff];
221221

222222
raw = raw6_local_deliver(skb, nexthdr);
223-
if ((ipprot = rcu_dereference(inet6_protos[nexthdr])) != NULL) {
223+
ipprot = rcu_dereference(inet6_protos[nexthdr]);
224+
if (ipprot != NULL) {
224225
int ret;
225226

226227
if (ipprot->flags & INET6_PROTO_FINAL) {

net/ipv6/ip6_output.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,8 @@ static int ip6_dst_lookup_tail(struct sock *sk,
898898
if (*dst == NULL)
899899
*dst = ip6_route_output(net, sk, fl6);
900900

901-
if ((err = (*dst)->error))
901+
err = (*dst)->error;
902+
if (err)
902903
goto out_err_release;
903904

904905
if (ipv6_addr_any(&fl6->saddr)) {
@@ -946,7 +947,8 @@ static int ip6_dst_lookup_tail(struct sock *sk,
946947
memcpy(&fl_gw6, fl6, sizeof(struct flowi6));
947948
memset(&fl_gw6.daddr, 0, sizeof(struct in6_addr));
948949
*dst = ip6_route_output(net, sk, &fl_gw6);
949-
if ((err = (*dst)->error))
950+
err = (*dst)->error;
951+
if (err)
950952
goto out_err_release;
951953
}
952954
}
@@ -1054,7 +1056,8 @@ static inline int ip6_ufo_append_data(struct sock *sk,
10541056
* device, so create one single skb packet containing complete
10551057
* udp datagram
10561058
*/
1057-
if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) {
1059+
skb = skb_peek_tail(&sk->sk_write_queue);
1060+
if (skb == NULL) {
10581061
skb = sock_alloc_send_skb(sk,
10591062
hh_len + fragheaderlen + transhdrlen + 20,
10601063
(flags & MSG_DONTWAIT), &err);
@@ -1534,7 +1537,8 @@ int ip6_push_pending_frames(struct sock *sk)
15341537
unsigned char proto = fl6->flowi6_proto;
15351538
int err = 0;
15361539

1537-
if ((skb = __skb_dequeue(&sk->sk_write_queue)) == NULL)
1540+
skb = __skb_dequeue(&sk->sk_write_queue);
1541+
if (skb == NULL)
15381542
goto out;
15391543
tail_skb = &(skb_shinfo(skb)->frag_list);
15401544

net/ipv6/ip6_tunnel.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,8 @@ ip6_tnl_err(struct sk_buff *skb, __u8 ipproto, struct inet6_skb_parm *opt,
501501
processing of the error. */
502502

503503
rcu_read_lock();
504-
if ((t = ip6_tnl_lookup(dev_net(skb->dev), &ipv6h->daddr,
505-
&ipv6h->saddr)) == NULL)
504+
t = ip6_tnl_lookup(dev_net(skb->dev), &ipv6h->daddr, &ipv6h->saddr);
505+
if (t == NULL)
506506
goto out;
507507

508508
tproto = ACCESS_ONCE(t->parms.proto);
@@ -550,7 +550,8 @@ ip6_tnl_err(struct sk_buff *skb, __u8 ipproto, struct inet6_skb_parm *opt,
550550
mtu = IPV6_MIN_MTU;
551551
t->dev->mtu = mtu;
552552

553-
if ((len = sizeof(*ipv6h) + ntohs(ipv6h->payload_len)) > mtu) {
553+
len = sizeof(*ipv6h) + ntohs(ipv6h->payload_len);
554+
if (len > mtu) {
554555
rel_type = ICMPV6_PKT_TOOBIG;
555556
rel_code = 0;
556557
rel_info = mtu;
@@ -811,9 +812,8 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol,
811812
int err;
812813

813814
rcu_read_lock();
814-
815-
if ((t = ip6_tnl_lookup(dev_net(skb->dev), &ipv6h->saddr,
816-
&ipv6h->daddr)) != NULL) {
815+
t = ip6_tnl_lookup(dev_net(skb->dev), &ipv6h->saddr, &ipv6h->daddr);
816+
if (t != NULL) {
817817
struct pcpu_sw_netstats *tstats;
818818

819819
tproto = ACCESS_ONCE(t->parms.proto);
@@ -1069,7 +1069,8 @@ static int ip6_tnl_xmit2(struct sk_buff *skb,
10691069
(skb_cloned(skb) && !skb_clone_writable(skb, 0))) {
10701070
struct sk_buff *new_skb;
10711071

1072-
if (!(new_skb = skb_realloc_headroom(skb, max_headroom)))
1072+
new_skb = skb_realloc_headroom(skb, max_headroom);
1073+
if (!new_skb)
10731074
goto tx_err_dst_release;
10741075

10751076
if (skb->sk)

net/ipv6/ip6_vti.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ static int vti6_rcv(struct sk_buff *skb)
287287
const struct ipv6hdr *ipv6h = ipv6_hdr(skb);
288288

289289
rcu_read_lock();
290-
if ((t = vti6_tnl_lookup(dev_net(skb->dev), &ipv6h->saddr,
291-
&ipv6h->daddr)) != NULL) {
290+
t = vti6_tnl_lookup(dev_net(skb->dev), &ipv6h->saddr, &ipv6h->daddr);
291+
if (t != NULL) {
292292
if (t->parms.proto != IPPROTO_IPV6 && t->parms.proto != 0) {
293293
rcu_read_unlock();
294294
goto discard;

net/ipv6/ndisc.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ static void ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data)
162162
memcpy(opt+2, data, data_len);
163163
data_len += 2;
164164
opt += data_len;
165-
if ((space -= data_len) > 0)
165+
space -= data_len;
166+
if (space > 0)
166167
memset(opt, 0, space);
167168
}
168169

@@ -656,8 +657,8 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
656657

657658
if (skb && ipv6_chk_addr(dev_net(dev), &ipv6_hdr(skb)->saddr, dev, 1))
658659
saddr = &ipv6_hdr(skb)->saddr;
659-
660-
if ((probes -= NEIGH_VAR(neigh->parms, UCAST_PROBES)) < 0) {
660+
probes -= NEIGH_VAR(neigh->parms, UCAST_PROBES);
661+
if (probes < 0) {
661662
if (!(neigh->nud_state & NUD_VALID)) {
662663
ND_PRINTK(1, dbg,
663664
"%s: trying to ucast probe in NUD_INVALID: %pI6\n",

net/ipv6/reassembly.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,8 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
429429
struct sk_buff *clone;
430430
int i, plen = 0;
431431

432-
if ((clone = alloc_skb(0, GFP_ATOMIC)) == NULL)
432+
clone = alloc_skb(0, GFP_ATOMIC);
433+
if (clone == NULL)
433434
goto out_oom;
434435
clone->next = head->next;
435436
head->next = clone;

net/ipv6/sit.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,8 @@ ipip6_tunnel_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
12411241
if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p)))
12421242
goto done;
12431243
err = -ENOENT;
1244-
if ((t = ipip6_tunnel_locate(net, &p, 0)) == NULL)
1244+
t = ipip6_tunnel_locate(net, &p, 0);
1245+
if (t == NULL)
12451246
goto done;
12461247
err = -EPERM;
12471248
if (t == netdev_priv(sitn->fb_tunnel_dev))
@@ -1836,8 +1837,8 @@ static int __net_init sit_init_net(struct net *net)
18361837
goto err_dev_free;
18371838

18381839
ipip6_tunnel_clone_6rd(sitn->fb_tunnel_dev, sitn);
1839-
1840-
if ((err = register_netdev(sitn->fb_tunnel_dev)))
1840+
err = register_netdev(sitn->fb_tunnel_dev);
1841+
if (err)
18411842
goto err_reg_dev;
18421843

18431844
t = netdev_priv(sitn->fb_tunnel_dev);

net/ipv6/udp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,8 @@ static struct sock *__udp6_lib_lookup_skb(struct sk_buff *skb,
357357
struct sock *sk;
358358
const struct ipv6hdr *iph = ipv6_hdr(skb);
359359

360-
if (unlikely(sk = skb_steal_sock(skb)))
360+
sk = skb_steal_sock(skb);
361+
if (unlikely(sk))
361362
return sk;
362363
return __udp6_lib_lookup(dev_net(skb_dst(skb)->dev), &iph->saddr, sport,
363364
&iph->daddr, dport, inet6_iif(skb),
@@ -1026,7 +1027,8 @@ static int udp_v6_push_pending_frames(struct sock *sk)
10261027
fl6 = &inet->cork.fl.u.ip6;
10271028

10281029
/* Grab the skbuff where UDP header space exists. */
1029-
if ((skb = skb_peek(&sk->sk_write_queue)) == NULL)
1030+
skb = skb_peek(&sk->sk_write_queue);
1031+
if (skb == NULL)
10301032
goto out;
10311033

10321034
/*

0 commit comments

Comments
 (0)