Skip to content

Commit 15be4ea

Browse files
committed
Merge branch 'l2tp-further-checkpatch-pl-cleanups'
Tom Parkin says: ==================== l2tp: further checkpatch.pl cleanups l2tp hasn't been kept up to date with the static analysis checks offered by checkpatch.pl. This patchset builds on the series "l2tp: cleanup checkpatch.pl warnings". It includes small refactoring changes which improve code quality and resolve a subset of the checkpatch warnings for the l2tp codebase. ==================== Reviewed-by: James Chapman <jchapman@katalix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 49b0aa1 + 70c05bf commit 15be4ea

6 files changed

Lines changed: 169 additions & 150 deletions

File tree

‎net/l2tp/l2tp_core.c‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ static void l2tp_recv_dequeue_skb(struct l2tp_session *session, struct sk_buff *
412412
}
413413

414414
/* call private receive handler */
415-
if (session->recv_skb != NULL)
415+
if (session->recv_skb)
416416
(*session->recv_skb)(session, skb, L2TP_SKB_CB(skb)->length);
417417
else
418418
kfree_skb(skb);
@@ -683,7 +683,7 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
683683
* check if we sre sending sequence numbers and if not,
684684
* configure it so.
685685
*/
686-
if ((!session->lns_mode) && (!session->send_seq)) {
686+
if (!session->lns_mode && !session->send_seq) {
687687
l2tp_info(session, L2TP_MSG_SEQ,
688688
"%s: requested to enable seq numbers by LNS\n",
689689
session->name);
@@ -707,7 +707,7 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
707707
* If we're the LNS and we're sending sequence numbers, the
708708
* LAC is broken. Discard the frame.
709709
*/
710-
if ((!session->lns_mode) && (session->send_seq)) {
710+
if (!session->lns_mode && session->send_seq) {
711711
l2tp_info(session, L2TP_MSG_SEQ,
712712
"%s: requested to disable seq numbers by LNS\n",
713713
session->name);
@@ -911,7 +911,7 @@ int l2tp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
911911
struct l2tp_tunnel *tunnel;
912912

913913
tunnel = rcu_dereference_sk_user_data(sk);
914-
if (tunnel == NULL)
914+
if (!tunnel)
915915
goto pass_up;
916916

917917
l2tp_dbg(tunnel, L2TP_MSG_DATA, "%s: received %d bytes\n",
@@ -1150,7 +1150,7 @@ static void l2tp_tunnel_destruct(struct sock *sk)
11501150
{
11511151
struct l2tp_tunnel *tunnel = l2tp_tunnel(sk);
11521152

1153-
if (tunnel == NULL)
1153+
if (!tunnel)
11541154
goto end;
11551155

11561156
l2tp_info(tunnel, L2TP_MSG_CONTROL, "%s: closing...\n", tunnel->name);
@@ -1189,7 +1189,7 @@ static void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel)
11891189
struct hlist_node *tmp;
11901190
struct l2tp_session *session;
11911191

1192-
BUG_ON(tunnel == NULL);
1192+
BUG_ON(!tunnel);
11931193

11941194
l2tp_info(tunnel, L2TP_MSG_CONTROL, "%s: closing all sessions...\n",
11951195
tunnel->name);
@@ -1214,7 +1214,7 @@ static void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel)
12141214
__l2tp_session_unhash(session);
12151215
l2tp_session_queue_purge(session);
12161216

1217-
if (session->session_close != NULL)
1217+
if (session->session_close)
12181218
(*session->session_close)(session);
12191219

12201220
l2tp_session_dec_refcount(session);
@@ -1389,7 +1389,7 @@ static int l2tp_tunnel_sock_create(struct net *net,
13891389

13901390
out:
13911391
*sockp = sock;
1392-
if ((err < 0) && sock) {
1392+
if (err < 0 && sock) {
13931393
kernel_sock_shutdown(sock, SHUT_RDWR);
13941394
sock_release(sock);
13951395
*sockp = NULL;
@@ -1407,11 +1407,11 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
14071407
int err;
14081408
enum l2tp_encap_type encap = L2TP_ENCAPTYPE_UDP;
14091409

1410-
if (cfg != NULL)
1410+
if (cfg)
14111411
encap = cfg->encap;
14121412

1413-
tunnel = kzalloc(sizeof(struct l2tp_tunnel), GFP_KERNEL);
1414-
if (tunnel == NULL) {
1413+
tunnel = kzalloc(sizeof(*tunnel), GFP_KERNEL);
1414+
if (!tunnel) {
14151415
err = -ENOMEM;
14161416
goto err;
14171417
}
@@ -1426,7 +1426,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
14261426
rwlock_init(&tunnel->hlist_lock);
14271427
tunnel->acpt_newsess = true;
14281428

1429-
if (cfg != NULL)
1429+
if (cfg)
14301430
tunnel->debug = cfg->debug;
14311431

14321432
tunnel->encap = encap;
@@ -1615,7 +1615,7 @@ int l2tp_session_delete(struct l2tp_session *session)
16151615

16161616
__l2tp_session_unhash(session);
16171617
l2tp_session_queue_purge(session);
1618-
if (session->session_close != NULL)
1618+
if (session->session_close)
16191619
(*session->session_close)(session);
16201620

16211621
l2tp_session_dec_refcount(session);
@@ -1647,8 +1647,8 @@ struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunn
16471647
{
16481648
struct l2tp_session *session;
16491649

1650-
session = kzalloc(sizeof(struct l2tp_session) + priv_size, GFP_KERNEL);
1651-
if (session != NULL) {
1650+
session = kzalloc(sizeof(*session) + priv_size, GFP_KERNEL);
1651+
if (session) {
16521652
session->magic = L2TP_SESSION_MAGIC;
16531653
session->tunnel = tunnel;
16541654

‎net/l2tp/l2tp_debugfs.c‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static void l2tp_dfs_next_session(struct l2tp_dfs_seq_data *pd)
5858
pd->session = l2tp_session_get_nth(pd->tunnel, pd->session_idx);
5959
pd->session_idx++;
6060

61-
if (pd->session == NULL) {
61+
if (!pd->session) {
6262
pd->session_idx = 0;
6363
l2tp_dfs_next_tunnel(pd);
6464
}
@@ -72,16 +72,16 @@ static void *l2tp_dfs_seq_start(struct seq_file *m, loff_t *offs)
7272
if (!pos)
7373
goto out;
7474

75-
BUG_ON(m->private == NULL);
75+
BUG_ON(!m->private);
7676
pd = m->private;
7777

78-
if (pd->tunnel == NULL)
78+
if (!pd->tunnel)
7979
l2tp_dfs_next_tunnel(pd);
8080
else
8181
l2tp_dfs_next_session(pd);
8282

8383
/* NULL tunnel and session indicates end of list */
84-
if ((pd->tunnel == NULL) && (pd->session == NULL))
84+
if (!pd->tunnel && !pd->session)
8585
pd = NULL;
8686

8787
out:
@@ -146,10 +146,12 @@ static void l2tp_dfs_seq_tunnel_show(struct seq_file *m, void *v)
146146

147147
seq_printf(m, " from %pI6c to %pI6c\n",
148148
&np->saddr, &tunnel->sock->sk_v6_daddr);
149-
} else
149+
}
150150
#endif
151-
seq_printf(m, " from %pI4 to %pI4\n",
152-
&inet->inet_saddr, &inet->inet_daddr);
151+
if (tunnel->sock->sk_family == AF_INET)
152+
seq_printf(m, " from %pI4 to %pI4\n",
153+
&inet->inet_saddr, &inet->inet_daddr);
154+
153155
if (tunnel->encap == L2TP_ENCAPTYPE_UDP)
154156
seq_printf(m, " source port %hu, dest port %hu\n",
155157
ntohs(inet->inet_sport), ntohs(inet->inet_dport));
@@ -221,7 +223,7 @@ static void l2tp_dfs_seq_session_show(struct seq_file *m, void *v)
221223
atomic_long_read(&session->stats.rx_bytes),
222224
atomic_long_read(&session->stats.rx_errors));
223225

224-
if (session->show != NULL)
226+
if (session->show)
225227
session->show(m, session);
226228
}
227229

@@ -268,7 +270,7 @@ static int l2tp_dfs_seq_open(struct inode *inode, struct file *file)
268270
int rc = -ENOMEM;
269271

270272
pd = kzalloc(sizeof(*pd), GFP_KERNEL);
271-
if (pd == NULL)
273+
if (!pd)
272274
goto out;
273275

274276
/* Derive the network namespace from the pid opening the

‎net/l2tp/l2tp_ip.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ static int l2tp_ip_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
471471
rt = (struct rtable *)__sk_dst_check(sk, 0);
472472

473473
rcu_read_lock();
474-
if (rt == NULL) {
474+
if (!rt) {
475475
const struct ip_options_rcu *inet_opt;
476476

477477
inet_opt = rcu_dereference(inet->inet_opt);

‎net/l2tp/l2tp_ip6.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ static int l2tp_ip6_push_pending_frames(struct sock *sk)
486486
int err = 0;
487487

488488
skb = skb_peek(&sk->sk_write_queue);
489-
if (skb == NULL)
489+
if (!skb)
490490
goto out;
491491

492492
transhdr = (__be32 *)skb_transport_header(skb);

0 commit comments

Comments
 (0)