Commit 0fef8f20 authored by Paul Gortmaker's avatar Paul Gortmaker

tipc: refactor accept() code for improved readability

In TIPC's accept() routine, there is a large block of code relating
to initialization of a new socket, all within an if condition checking
if the allocation succeeded.

Here, we simply flip the check of the if, so that the main execution
path stays at the same indentation level, which improves readability.
If the allocation fails, we jump to an already existing exit label.
Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
parent 258f8667
...@@ -1509,8 +1509,13 @@ static int listen(struct socket *sock, int len) ...@@ -1509,8 +1509,13 @@ static int listen(struct socket *sock, int len)
*/ */
static int accept(struct socket *sock, struct socket *new_sock, int flags) static int accept(struct socket *sock, struct socket *new_sock, int flags)
{ {
struct sock *sk = sock->sk; struct sock *new_sk, *sk = sock->sk;
struct sk_buff *buf; struct sk_buff *buf;
struct tipc_sock *new_tsock;
struct tipc_port *new_tport;
struct tipc_msg *msg;
u32 new_ref;
int res; int res;
lock_sock(sk); lock_sock(sk);
...@@ -1536,12 +1541,14 @@ static int accept(struct socket *sock, struct socket *new_sock, int flags) ...@@ -1536,12 +1541,14 @@ static int accept(struct socket *sock, struct socket *new_sock, int flags)
buf = skb_peek(&sk->sk_receive_queue); buf = skb_peek(&sk->sk_receive_queue);
res = tipc_create(sock_net(sock->sk), new_sock, 0, 0); res = tipc_create(sock_net(sock->sk), new_sock, 0, 0);
if (!res) { if (res)
struct sock *new_sk = new_sock->sk; goto exit;
struct tipc_sock *new_tsock = tipc_sk(new_sk);
struct tipc_port *new_tport = new_tsock->p; new_sk = new_sock->sk;
u32 new_ref = new_tport->ref; new_tsock = tipc_sk(new_sk);
struct tipc_msg *msg = buf_msg(buf); new_tport = new_tsock->p;
new_ref = new_tport->ref;
msg = buf_msg(buf);
/* we lock on new_sk; but lockdep sees the lock on sk */ /* we lock on new_sk; but lockdep sees the lock on sk */
lock_sock_nested(new_sk, SINGLE_DEPTH_NESTING); lock_sock_nested(new_sk, SINGLE_DEPTH_NESTING);
...@@ -1578,7 +1585,7 @@ static int accept(struct socket *sock, struct socket *new_sock, int flags) ...@@ -1578,7 +1585,7 @@ static int accept(struct socket *sock, struct socket *new_sock, int flags)
__skb_queue_head(&new_sk->sk_receive_queue, buf); __skb_queue_head(&new_sk->sk_receive_queue, buf);
} }
release_sock(new_sk); release_sock(new_sk);
}
exit: exit:
release_sock(sk); release_sock(sk);
return res; return res;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment