Skip to content

Commit b71a61c

Browse files
tomparkindavem330
authored andcommitted
l2tp: cleanup whitespace use
Fix up various whitespace issues as reported by checkpatch.pl: * remove spaces around operators where appropriate, * add missing blank lines following declarations, * remove multiple blank lines, or trailing blank lines at the end of functions. Signed-off-by: Tom Parkin <tparkin@katalix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 637989b commit b71a61c

7 files changed

Lines changed: 48 additions & 48 deletions

File tree

‎net/l2tp/l2tp_core.c‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ struct l2tp_skb_cb {
9494
unsigned long expires;
9595
};
9696

97-
#define L2TP_SKB_CB(skb) ((struct l2tp_skb_cb *) &skb->cb[sizeof(struct inet_skb_parm)])
97+
#define L2TP_SKB_CB(skb) ((struct l2tp_skb_cb *)&skb->cb[sizeof(struct inet_skb_parm)])
9898

9999
static struct workqueue_struct *l2tp_wq;
100100

@@ -134,7 +134,6 @@ static inline struct hlist_head *
134134
l2tp_session_id_hash_2(struct l2tp_net *pn, u32 session_id)
135135
{
136136
return &pn->l2tp_session_hlist[hash_32(session_id, L2TP_HASH_BITS_2)];
137-
138137
}
139138

140139
/* Session hash list.
@@ -648,9 +647,9 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
648647
L2TP_SKB_CB(skb)->has_seq = 0;
649648
if (tunnel->version == L2TP_HDR_VER_2) {
650649
if (hdrflags & L2TP_HDRFLAG_S) {
651-
ns = ntohs(*(__be16 *) ptr);
650+
ns = ntohs(*(__be16 *)ptr);
652651
ptr += 2;
653-
nr = ntohs(*(__be16 *) ptr);
652+
nr = ntohs(*(__be16 *)ptr);
654653
ptr += 2;
655654

656655
/* Store L2TP info in the skb */
@@ -662,7 +661,7 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
662661
session->name, ns, nr, session->nr);
663662
}
664663
} else if (session->l2specific_type == L2TP_L2SPECTYPE_DEFAULT) {
665-
u32 l2h = ntohl(*(__be32 *) ptr);
664+
u32 l2h = ntohl(*(__be32 *)ptr);
666665

667666
if (l2h & 0x40000000) {
668667
ns = l2h & 0x00ffffff;
@@ -777,6 +776,7 @@ EXPORT_SYMBOL(l2tp_recv_common);
777776
static int l2tp_session_queue_purge(struct l2tp_session *session)
778777
{
779778
struct sk_buff *skb = NULL;
779+
780780
BUG_ON(!session);
781781
BUG_ON(session->magic != L2TP_SESSION_MAGIC);
782782
while ((skb = skb_dequeue(&session->reorder_q))) {
@@ -828,7 +828,7 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb)
828828
optr = ptr = skb->data;
829829

830830
/* Get L2TP header flags */
831-
hdrflags = ntohs(*(__be16 *) ptr);
831+
hdrflags = ntohs(*(__be16 *)ptr);
832832

833833
/* Check protocol version */
834834
version = hdrflags & L2TP_HDR_VER_MASK;
@@ -859,14 +859,14 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb)
859859
ptr += 2;
860860

861861
/* Extract tunnel and session ID */
862-
tunnel_id = ntohs(*(__be16 *) ptr);
862+
tunnel_id = ntohs(*(__be16 *)ptr);
863863
ptr += 2;
864-
session_id = ntohs(*(__be16 *) ptr);
864+
session_id = ntohs(*(__be16 *)ptr);
865865
ptr += 2;
866866
} else {
867867
ptr += 2; /* skip reserved bits */
868868
tunnel_id = tunnel->tunnel_id;
869-
session_id = ntohl(*(__be32 *) ptr);
869+
session_id = ntohl(*(__be32 *)ptr);
870870
ptr += 4;
871871
}
872872

@@ -971,13 +971,13 @@ static int l2tp_build_l2tpv3_header(struct l2tp_session *session, void *buf)
971971
*/
972972
if (tunnel->encap == L2TP_ENCAPTYPE_UDP) {
973973
u16 flags = L2TP_HDR_VER_3;
974-
*((__be16 *) bufp) = htons(flags);
974+
*((__be16 *)bufp) = htons(flags);
975975
bufp += 2;
976-
*((__be16 *) bufp) = 0;
976+
*((__be16 *)bufp) = 0;
977977
bufp += 2;
978978
}
979979

980-
*((__be32 *) bufp) = htonl(session->peer_session_id);
980+
*((__be32 *)bufp) = htonl(session->peer_session_id);
981981
bufp += 4;
982982
if (session->cookie_len) {
983983
memcpy(bufp, &session->cookie[0], session->cookie_len);
@@ -1305,9 +1305,9 @@ static int l2tp_tunnel_sock_create(struct net *net,
13051305
memcpy(&udp_conf.peer_ip6, cfg->peer_ip6,
13061306
sizeof(udp_conf.peer_ip6));
13071307
udp_conf.use_udp6_tx_checksums =
1308-
! cfg->udp6_zero_tx_checksums;
1308+
!cfg->udp6_zero_tx_checksums;
13091309
udp_conf.use_udp6_rx_checksums =
1310-
! cfg->udp6_zero_rx_checksums;
1310+
!cfg->udp6_zero_rx_checksums;
13111311
} else
13121312
#endif
13131313
{
@@ -1340,7 +1340,7 @@ static int l2tp_tunnel_sock_create(struct net *net,
13401340
memcpy(&ip6_addr.l2tp_addr, cfg->local_ip6,
13411341
sizeof(ip6_addr.l2tp_addr));
13421342
ip6_addr.l2tp_conn_id = tunnel_id;
1343-
err = kernel_bind(sock, (struct sockaddr *) &ip6_addr,
1343+
err = kernel_bind(sock, (struct sockaddr *)&ip6_addr,
13441344
sizeof(ip6_addr));
13451345
if (err < 0)
13461346
goto out;
@@ -1350,7 +1350,7 @@ static int l2tp_tunnel_sock_create(struct net *net,
13501350
sizeof(ip6_addr.l2tp_addr));
13511351
ip6_addr.l2tp_conn_id = peer_tunnel_id;
13521352
err = kernel_connect(sock,
1353-
(struct sockaddr *) &ip6_addr,
1353+
(struct sockaddr *)&ip6_addr,
13541354
sizeof(ip6_addr), 0);
13551355
if (err < 0)
13561356
goto out;
@@ -1367,15 +1367,15 @@ static int l2tp_tunnel_sock_create(struct net *net,
13671367
ip_addr.l2tp_family = AF_INET;
13681368
ip_addr.l2tp_addr = cfg->local_ip;
13691369
ip_addr.l2tp_conn_id = tunnel_id;
1370-
err = kernel_bind(sock, (struct sockaddr *) &ip_addr,
1370+
err = kernel_bind(sock, (struct sockaddr *)&ip_addr,
13711371
sizeof(ip_addr));
13721372
if (err < 0)
13731373
goto out;
13741374

13751375
ip_addr.l2tp_family = AF_INET;
13761376
ip_addr.l2tp_addr = cfg->peer_ip;
13771377
ip_addr.l2tp_conn_id = peer_tunnel_id;
1378-
err = kernel_connect(sock, (struct sockaddr *) &ip_addr,
1378+
err = kernel_connect(sock, (struct sockaddr *)&ip_addr,
13791379
sizeof(ip_addr), 0);
13801380
if (err < 0)
13811381
goto out;
@@ -1593,6 +1593,7 @@ void __l2tp_session_unhash(struct l2tp_session *session)
15931593
/* For L2TPv3 we have a per-net hash: remove from there, too */
15941594
if (tunnel->version != L2TP_HDR_VER_2) {
15951595
struct l2tp_net *pn = l2tp_pernet(tunnel->l2tp_net);
1596+
15961597
spin_lock_bh(&pn->l2tp_session_hlist_lock);
15971598
hlist_del_init_rcu(&session->global_hlist);
15981599
spin_unlock_bh(&pn->l2tp_session_hlist_lock);
@@ -1636,7 +1637,6 @@ void l2tp_session_set_header_len(struct l2tp_session *session, int version)
16361637
if (session->tunnel->encap == L2TP_ENCAPTYPE_UDP)
16371638
session->hdr_len += 4;
16381639
}
1639-
16401640
}
16411641
EXPORT_SYMBOL_GPL(l2tp_session_set_header_len);
16421642

‎net/l2tp/l2tp_debugfs.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ static void l2tp_dfs_next_session(struct l2tp_dfs_seq_data *pd)
6363
pd->session_idx = 0;
6464
l2tp_dfs_next_tunnel(pd);
6565
}
66-
6766
}
6867

6968
static void *l2tp_dfs_seq_start(struct seq_file *m, loff_t *offs)
@@ -90,7 +89,6 @@ static void *l2tp_dfs_seq_start(struct seq_file *m, loff_t *offs)
9089
return pd;
9190
}
9291

93-
9492
static void *l2tp_dfs_seq_next(struct seq_file *m, void *v, loff_t *pos)
9593
{
9694
(*pos)++;

‎net/l2tp/l2tp_eth.c‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ struct l2tp_eth_sess {
5151
struct net_device __rcu *dev;
5252
};
5353

54-
5554
static int l2tp_eth_dev_init(struct net_device *dev)
5655
{
5756
eth_hw_addr_random(dev);
@@ -94,13 +93,12 @@ static void l2tp_eth_get_stats64(struct net_device *dev,
9493
{
9594
struct l2tp_eth *priv = netdev_priv(dev);
9695

97-
stats->tx_bytes = (unsigned long) atomic_long_read(&priv->tx_bytes);
98-
stats->tx_packets = (unsigned long) atomic_long_read(&priv->tx_packets);
99-
stats->tx_dropped = (unsigned long) atomic_long_read(&priv->tx_dropped);
100-
stats->rx_bytes = (unsigned long) atomic_long_read(&priv->rx_bytes);
101-
stats->rx_packets = (unsigned long) atomic_long_read(&priv->rx_packets);
102-
stats->rx_errors = (unsigned long) atomic_long_read(&priv->rx_errors);
103-
96+
stats->tx_bytes = (unsigned long)atomic_long_read(&priv->tx_bytes);
97+
stats->tx_packets = (unsigned long)atomic_long_read(&priv->tx_packets);
98+
stats->tx_dropped = (unsigned long)atomic_long_read(&priv->tx_dropped);
99+
stats->rx_bytes = (unsigned long)atomic_long_read(&priv->rx_bytes);
100+
stats->rx_packets = (unsigned long)atomic_long_read(&priv->rx_packets);
101+
stats->rx_errors = (unsigned long)atomic_long_read(&priv->rx_errors);
104102
}
105103

106104
static const struct net_device_ops l2tp_eth_netdev_ops = {
@@ -348,13 +346,11 @@ static int l2tp_eth_create(struct net *net, struct l2tp_tunnel *tunnel,
348346
return rc;
349347
}
350348

351-
352349
static const struct l2tp_nl_cmd_ops l2tp_eth_nl_cmd_ops = {
353350
.session_create = l2tp_eth_create,
354351
.session_delete = l2tp_session_delete,
355352
};
356353

357-
358354
static int __init l2tp_eth_init(void)
359355
{
360356
int err = 0;

‎net/l2tp/l2tp_ip.c‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static int l2tp_ip_recv(struct sk_buff *skb)
126126

127127
/* Point to L2TP header */
128128
optr = ptr = skb->data;
129-
session_id = ntohl(*((__be32 *) ptr));
129+
session_id = ntohl(*((__be32 *)ptr));
130130
ptr += 4;
131131

132132
/* RFC3931: L2TP/IP packets have the first 4 bytes containing
@@ -176,7 +176,7 @@ static int l2tp_ip_recv(struct sk_buff *skb)
176176
if ((skb->data[0] & 0xc0) != 0xc0)
177177
goto discard;
178178

179-
tunnel_id = ntohl(*(__be32 *) &skb->data[4]);
179+
tunnel_id = ntohl(*(__be32 *)&skb->data[4]);
180180
iph = (struct iphdr *)skb_network_header(skb);
181181

182182
read_lock_bh(&l2tp_ip_lock);
@@ -260,7 +260,7 @@ static void l2tp_ip_destroy_sock(struct sock *sk)
260260
static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
261261
{
262262
struct inet_sock *inet = inet_sk(sk);
263-
struct sockaddr_l2tpip *addr = (struct sockaddr_l2tpip *) uaddr;
263+
struct sockaddr_l2tpip *addr = (struct sockaddr_l2tpip *)uaddr;
264264
struct net *net = sock_net(sk);
265265
int ret;
266266
int chk_addr_ret;
@@ -316,7 +316,7 @@ static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
316316

317317
static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
318318
{
319-
struct sockaddr_l2tpip *lsa = (struct sockaddr_l2tpip *) uaddr;
319+
struct sockaddr_l2tpip *lsa = (struct sockaddr_l2tpip *)uaddr;
320320
int rc;
321321

322322
if (addr_len < sizeof(*lsa))
@@ -375,6 +375,7 @@ static int l2tp_ip_getname(struct socket *sock, struct sockaddr *uaddr,
375375
lsa->l2tp_addr.s_addr = inet->inet_daddr;
376376
} else {
377377
__be32 addr = inet->inet_rcv_saddr;
378+
378379
if (!addr)
379380
addr = inet->inet_saddr;
380381
lsa->l2tp_conn_id = lsk->conn_id;
@@ -422,6 +423,7 @@ static int l2tp_ip_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
422423
/* Get and verify the address. */
423424
if (msg->msg_name) {
424425
DECLARE_SOCKADDR(struct sockaddr_l2tpip *, lip, msg->msg_name);
426+
425427
rc = -EINVAL;
426428
if (msg->msg_namelen < sizeof(*lip))
427429
goto out;
@@ -456,7 +458,7 @@ static int l2tp_ip_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
456458
skb_reset_transport_header(skb);
457459

458460
/* Insert 0 session_id */
459-
*((__be32 *) skb_put(skb, 4)) = 0;
461+
*((__be32 *)skb_put(skb, 4)) = 0;
460462

461463
/* Copy user data into skb */
462464
rc = memcpy_from_msg(skb_put(skb, len), msg, len);
@@ -467,7 +469,7 @@ static int l2tp_ip_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
467469

468470
fl4 = &inet->cork.fl.u.ip4;
469471
if (connected)
470-
rt = (struct rtable *) __sk_dst_check(sk, 0);
472+
rt = (struct rtable *)__sk_dst_check(sk, 0);
471473

472474
rcu_read_lock();
473475
if (rt == NULL) {

‎net/l2tp/l2tp_ip6.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static int l2tp_ip6_recv(struct sk_buff *skb)
138138

139139
/* Point to L2TP header */
140140
optr = ptr = skb->data;
141-
session_id = ntohl(*((__be32 *) ptr));
141+
session_id = ntohl(*((__be32 *)ptr));
142142
ptr += 4;
143143

144144
/* RFC3931: L2TP/IP packets have the first 4 bytes containing
@@ -188,7 +188,7 @@ static int l2tp_ip6_recv(struct sk_buff *skb)
188188
if ((skb->data[0] & 0xc0) != 0xc0)
189189
goto discard;
190190

191-
tunnel_id = ntohl(*(__be32 *) &skb->data[4]);
191+
tunnel_id = ntohl(*(__be32 *)&skb->data[4]);
192192
iph = ipv6_hdr(skb);
193193

194194
read_lock_bh(&l2tp_ip6_lock);
@@ -276,7 +276,7 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
276276
{
277277
struct inet_sock *inet = inet_sk(sk);
278278
struct ipv6_pinfo *np = inet6_sk(sk);
279-
struct sockaddr_l2tpip6 *addr = (struct sockaddr_l2tpip6 *) uaddr;
279+
struct sockaddr_l2tpip6 *addr = (struct sockaddr_l2tpip6 *)uaddr;
280280
struct net *net = sock_net(sk);
281281
__be32 v4addr = 0;
282282
int bound_dev_if;
@@ -375,8 +375,8 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
375375
static int l2tp_ip6_connect(struct sock *sk, struct sockaddr *uaddr,
376376
int addr_len)
377377
{
378-
struct sockaddr_l2tpip6 *lsa = (struct sockaddr_l2tpip6 *) uaddr;
379-
struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr;
378+
struct sockaddr_l2tpip6 *lsa = (struct sockaddr_l2tpip6 *)uaddr;
379+
struct sockaddr_in6 *usin = (struct sockaddr_in6 *)uaddr;
380380
struct in6_addr *daddr;
381381
int addr_type;
382382
int rc;
@@ -548,7 +548,7 @@ static int l2tp_ip6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
548548
daddr = &lsa->l2tp_addr;
549549
if (np->sndflow) {
550550
fl6.flowlabel = lsa->l2tp_flowinfo & IPV6_FLOWINFO_MASK;
551-
if (fl6.flowlabel&IPV6_FLOWLABEL_MASK) {
551+
if (fl6.flowlabel & IPV6_FLOWLABEL_MASK) {
552552
flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
553553
if (IS_ERR(flowlabel))
554554
return -EINVAL;
@@ -594,7 +594,7 @@ static int l2tp_ip6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
594594
if (IS_ERR(flowlabel))
595595
return -EINVAL;
596596
}
597-
if (!(opt->opt_nflen|opt->opt_flen))
597+
if (!(opt->opt_nflen | opt->opt_flen))
598598
opt = NULL;
599599
}
600600

‎net/l2tp/l2tp_netlink.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
#include "l2tp_core.h"
2929

30-
3130
static struct genl_family l2tp_nl_family;
3231

3332
static const struct genl_multicast_group l2tp_multicast_group[] = {
@@ -570,6 +569,7 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf
570569

571570
if (info->attrs[L2TP_ATTR_COOKIE]) {
572571
u16 len = nla_len(info->attrs[L2TP_ATTR_COOKIE]);
572+
573573
if (len > 8) {
574574
ret = -EINVAL;
575575
goto out_tunnel;
@@ -579,6 +579,7 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf
579579
}
580580
if (info->attrs[L2TP_ATTR_PEER_COOKIE]) {
581581
u16 len = nla_len(info->attrs[L2TP_ATTR_PEER_COOKIE]);
582+
582583
if (len > 8) {
583584
ret = -EINVAL;
584585
goto out_tunnel;

0 commit comments

Comments
 (0)