Skip to content

Commit

Permalink
Merge branch 'l2tp-further-checkpatch-pl-cleanups'
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David S. Miller committed Jul 23, 2020
2 parents 49b0aa1 + 70c05bf commit 15be4ea
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 150 deletions.
30 changes: 15 additions & 15 deletions net/l2tp/l2tp_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ static void l2tp_recv_dequeue_skb(struct l2tp_session *session, struct sk_buff *
}

/* call private receive handler */
if (session->recv_skb != NULL)
if (session->recv_skb)
(*session->recv_skb)(session, skb, L2TP_SKB_CB(skb)->length);
else
kfree_skb(skb);
Expand Down Expand Up @@ -683,7 +683,7 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
* check if we sre sending sequence numbers and if not,
* configure it so.
*/
if ((!session->lns_mode) && (!session->send_seq)) {
if (!session->lns_mode && !session->send_seq) {
l2tp_info(session, L2TP_MSG_SEQ,
"%s: requested to enable seq numbers by LNS\n",
session->name);
Expand All @@ -707,7 +707,7 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
* If we're the LNS and we're sending sequence numbers, the
* LAC is broken. Discard the frame.
*/
if ((!session->lns_mode) && (session->send_seq)) {
if (!session->lns_mode && session->send_seq) {
l2tp_info(session, L2TP_MSG_SEQ,
"%s: requested to disable seq numbers by LNS\n",
session->name);
Expand Down Expand Up @@ -911,7 +911,7 @@ int l2tp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
struct l2tp_tunnel *tunnel;

tunnel = rcu_dereference_sk_user_data(sk);
if (tunnel == NULL)
if (!tunnel)
goto pass_up;

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

if (tunnel == NULL)
if (!tunnel)
goto end;

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

BUG_ON(tunnel == NULL);
BUG_ON(!tunnel);

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

if (session->session_close != NULL)
if (session->session_close)
(*session->session_close)(session);

l2tp_session_dec_refcount(session);
Expand Down Expand Up @@ -1389,7 +1389,7 @@ static int l2tp_tunnel_sock_create(struct net *net,

out:
*sockp = sock;
if ((err < 0) && sock) {
if (err < 0 && sock) {
kernel_sock_shutdown(sock, SHUT_RDWR);
sock_release(sock);
*sockp = NULL;
Expand All @@ -1407,11 +1407,11 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
int err;
enum l2tp_encap_type encap = L2TP_ENCAPTYPE_UDP;

if (cfg != NULL)
if (cfg)
encap = cfg->encap;

tunnel = kzalloc(sizeof(struct l2tp_tunnel), GFP_KERNEL);
if (tunnel == NULL) {
tunnel = kzalloc(sizeof(*tunnel), GFP_KERNEL);
if (!tunnel) {
err = -ENOMEM;
goto err;
}
Expand All @@ -1426,7 +1426,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
rwlock_init(&tunnel->hlist_lock);
tunnel->acpt_newsess = true;

if (cfg != NULL)
if (cfg)
tunnel->debug = cfg->debug;

tunnel->encap = encap;
Expand Down Expand Up @@ -1615,7 +1615,7 @@ int l2tp_session_delete(struct l2tp_session *session)

__l2tp_session_unhash(session);
l2tp_session_queue_purge(session);
if (session->session_close != NULL)
if (session->session_close)
(*session->session_close)(session);

l2tp_session_dec_refcount(session);
Expand Down Expand Up @@ -1647,8 +1647,8 @@ struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunn
{
struct l2tp_session *session;

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

Expand Down
20 changes: 11 additions & 9 deletions net/l2tp/l2tp_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static void l2tp_dfs_next_session(struct l2tp_dfs_seq_data *pd)
pd->session = l2tp_session_get_nth(pd->tunnel, pd->session_idx);
pd->session_idx++;

if (pd->session == NULL) {
if (!pd->session) {
pd->session_idx = 0;
l2tp_dfs_next_tunnel(pd);
}
Expand All @@ -72,16 +72,16 @@ static void *l2tp_dfs_seq_start(struct seq_file *m, loff_t *offs)
if (!pos)
goto out;

BUG_ON(m->private == NULL);
BUG_ON(!m->private);
pd = m->private;

if (pd->tunnel == NULL)
if (!pd->tunnel)
l2tp_dfs_next_tunnel(pd);
else
l2tp_dfs_next_session(pd);

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

out:
Expand Down Expand Up @@ -146,10 +146,12 @@ static void l2tp_dfs_seq_tunnel_show(struct seq_file *m, void *v)

seq_printf(m, " from %pI6c to %pI6c\n",
&np->saddr, &tunnel->sock->sk_v6_daddr);
} else
}
#endif
seq_printf(m, " from %pI4 to %pI4\n",
&inet->inet_saddr, &inet->inet_daddr);
if (tunnel->sock->sk_family == AF_INET)
seq_printf(m, " from %pI4 to %pI4\n",
&inet->inet_saddr, &inet->inet_daddr);

if (tunnel->encap == L2TP_ENCAPTYPE_UDP)
seq_printf(m, " source port %hu, dest port %hu\n",
ntohs(inet->inet_sport), ntohs(inet->inet_dport));
Expand Down Expand Up @@ -221,7 +223,7 @@ static void l2tp_dfs_seq_session_show(struct seq_file *m, void *v)
atomic_long_read(&session->stats.rx_bytes),
atomic_long_read(&session->stats.rx_errors));

if (session->show != NULL)
if (session->show)
session->show(m, session);
}

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

pd = kzalloc(sizeof(*pd), GFP_KERNEL);
if (pd == NULL)
if (!pd)
goto out;

/* Derive the network namespace from the pid opening the
Expand Down
2 changes: 1 addition & 1 deletion net/l2tp/l2tp_ip.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ static int l2tp_ip_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
rt = (struct rtable *)__sk_dst_check(sk, 0);

rcu_read_lock();
if (rt == NULL) {
if (!rt) {
const struct ip_options_rcu *inet_opt;

inet_opt = rcu_dereference(inet->inet_opt);
Expand Down
2 changes: 1 addition & 1 deletion net/l2tp/l2tp_ip6.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ static int l2tp_ip6_push_pending_frames(struct sock *sk)
int err = 0;

skb = skb_peek(&sk->sk_write_queue);
if (skb == NULL)
if (!skb)
goto out;

transhdr = (__be32 *)skb_transport_header(skb);
Expand Down
Loading

0 comments on commit 15be4ea

Please sign in to comment.