Skip to content

Commit

Permalink
tcp: remove redundant SOCK_DONE checks
Browse files Browse the repository at this point in the history
In both tcp_splice_read() and tcp_recvmsg(), we already test
sock_flag(sk, SOCK_DONE) right before evaluating sk->sk_state,
so "!sock_flag(sk, SOCK_DONE)" is always true.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Jul 8, 2018
1 parent 3d907ea commit c47078d
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions net/ipv4/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,7 @@ ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos,
* This occurs when user tries to read
* from never connected socket.
*/
if (!sock_flag(sk, SOCK_DONE))
ret = -ENOTCONN;
ret = -ENOTCONN;
break;
}
if (!timeo) {
Expand Down Expand Up @@ -2042,13 +2041,10 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
break;

if (sk->sk_state == TCP_CLOSE) {
if (!sock_flag(sk, SOCK_DONE)) {
/* This occurs when user tries to read
* from never connected socket.
*/
copied = -ENOTCONN;
break;
}
/* This occurs when user tries to read
* from never connected socket.
*/
copied = -ENOTCONN;
break;
}

Expand Down

0 comments on commit c47078d

Please sign in to comment.