[openib-general] [PATCH][SDP][7/22] Whitespace cleanup in sdp_inet.c
Tom Duffy
Tom.Duffy at Sun.COM
Fri Feb 18 16:45:34 PST 2005
Signed-off-by: Tom Duffy <tduffy at sun.com>
Index: linux-2.6.10-openib/drivers/infiniband/ulp/sdp/sdp_inet.c
===================================================================
--- linux-2.6.10-openib/drivers/infiniband/ulp/sdp/sdp_inet.c (revision 1836)
+++ linux-2.6.10-openib/drivers/infiniband/ulp/sdp/sdp_inet.c (working copy)
@@ -103,24 +103,18 @@ void sdp_inet_wake_send(struct sock *sk)
{
struct sdp_opt *conn;
- if (NULL == sk ||
- NULL == (conn = SDP_GET_CONN(sk))) {
-
+ if (NULL == sk || NULL == (conn = SDP_GET_CONN(sk)))
return;
- }
if (NULL != sk->sk_socket &&
0 < test_bit(SOCK_NOSPACE, &sk->sk_socket->flags) &&
0 < __sdp_inet_writable(conn)) {
-
read_lock(&sk->sk_callback_lock);
clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
if (NULL != sk->sk_sleep &&
- 0 < waitqueue_active(sk->sk_sleep)) {
-
+ 0 < waitqueue_active(sk->sk_sleep))
wake_up_interruptible(sk->sk_sleep);
- }
/*
* test, clear, and notify. SOCK_ASYNC_NOSPACE
*/
@@ -137,14 +131,10 @@ void sdp_inet_wake_send(struct sock *sk)
void sdp_inet_wake_generic(struct sock *sk)
{
if (NULL != sk) {
-
read_lock(&sk->sk_callback_lock);
- if (NULL != sk->sk_sleep &&
- waitqueue_active(sk->sk_sleep)) {
-
+ if (NULL != sk->sk_sleep && waitqueue_active(sk->sk_sleep))
wake_up_interruptible_all(sk->sk_sleep);
- }
read_unlock(&sk->sk_callback_lock);
}
@@ -158,12 +148,9 @@ void sdp_inet_wake_generic(struct sock *
void sdp_inet_wake_recv(struct sock *sk, int len)
{
if (NULL != sk) {
-
read_lock(&sk->sk_callback_lock);
- if (NULL != sk->sk_sleep) {
-
+ if (NULL != sk->sk_sleep)
wake_up_interruptible(sk->sk_sleep);
- }
sk_wake_async(sk, 1, POLL_IN);
read_unlock(&sk->sk_callback_lock);
@@ -178,12 +165,9 @@ void sdp_inet_wake_recv(struct sock *sk,
void sdp_inet_wake_error(struct sock *sk)
{
if (NULL != sk) {
-
read_lock(&sk->sk_callback_lock);
- if (NULL != sk->sk_sleep) {
-
+ if (NULL != sk->sk_sleep)
wake_up_interruptible(sk->sk_sleep);
- }
sk_wake_async(sk, 0, POLL_ERR);
read_unlock(&sk->sk_callback_lock);
@@ -201,9 +185,8 @@ void sdp_inet_wake_urg(struct sock *sk)
* pid for SIGURG/SIGIO has been set. On positive send signal to
* process, on negative send signal to processes group.
*/
- if (NULL != sk) {
+ if (NULL != sk)
sk_send_sigurg(sk);
- }
return;
} /* sdp_inet_wake_urg */
@@ -224,18 +207,15 @@ static int _sdp_inet_abort(struct sdp_op
conn->send_buf = 0;
switch (conn->istate) {
-
case SDP_SOCK_ST_CONNECT:
case SDP_SOCK_ST_ACCEPTING:
case SDP_SOCK_ST_ACCEPTED:
-
sdp_dbg_warn(conn, "Unexpected abort");
case SDP_SOCK_ST_ESTABLISHED:
case SDP_SOCK_ST_CLOSE:
case SDP_SOCK_ST_DISCONNECT:
case SDP_SOCK_ST_CLOSING:
-
result = sdp_wall_abort(conn);
if (0 > result) {
@@ -248,14 +228,12 @@ static int _sdp_inet_abort(struct sdp_op
case SDP_SOCK_ST_LISTEN:
case SDP_SOCK_ST_CLOSED:
case SDP_SOCK_ST_ERROR:
-
sdp_dbg_warn(conn, "Unhandled abort");
conn->istate = SDP_SOCK_ST_ERROR;
result = -EINVAL;
break;
default:
-
sdp_dbg_warn(conn, "Unknown abort state");
conn->istate = SDP_SOCK_ST_ERROR;
@@ -276,37 +254,28 @@ static int _sdp_inet_disconnect(struct s
SDP_CHECK_NULL(conn, -EINVAL);
switch (conn->istate) {
-
case SDP_SOCK_ST_CONNECT:
-
result = sdp_wall_abort(conn);
if (0 > result) {
-
result = -ECONNABORTED;
SDP_CONN_SET_ERR(conn, ECONNABORTED);
conn->istate = SDP_SOCK_ST_ERROR;
}
-
break;
case SDP_SOCK_ST_ESTABLISHED:
case SDP_SOCK_ST_ACCEPTED:
-
conn->istate = SDP_SOCK_ST_DISCONNECT;
result = sdp_wall_send_close(conn);
if (0 > result) {
-
result = -ECONNABORTED;
SDP_CONN_SET_ERR(conn, ECONNABORTED);
conn->istate = SDP_SOCK_ST_ERROR;
}
-
break;
case SDP_SOCK_ST_CLOSE:
-
conn->istate = SDP_SOCK_ST_CLOSING;
result = sdp_wall_send_closing(conn);
if (0 > result) {
-
result = -ECONNABORTED;
SDP_CONN_SET_ERR(conn, ECONNABORTED);
conn->istate = SDP_SOCK_ST_ERROR;
@@ -325,12 +294,9 @@ static int _sdp_inet_disconnect(struct s
case SDP_SOCK_ST_LISTEN:
case SDP_SOCK_ST_CLOSED:
case SDP_SOCK_ST_ERROR:
-
break;
default:
-
sdp_dbg_warn(conn, "Unknown disconnect state");
-
conn->istate = SDP_SOCK_ST_ERROR;
result = -EINVAL;
break;
@@ -358,7 +324,6 @@ static int _sdp_inet_release(struct sock
SDP_CHECK_NULL(sock->file, -EINVAL);
if (NULL == sock->sk) {
-
sdp_dbg_warn(NULL, "release empty <%d:%d> flags <%08lx>",
sock->type, sock->state, sock->flags);
return 0;
@@ -383,26 +348,20 @@ static int _sdp_inet_release(struct sock
* stop listening
*/
result = sdp_inet_listen_stop(conn);
- if (0 > result) {
-
+ if (0 > result)
sdp_dbg_warn(conn, "Error <%d> while releasing listen",
result);
- }
goto done;
}
/*
* get blocking nature of the socket.
*/
- if (sock->file) {
-
+ if (sock->file)
flags = (0 < (sock->file->f_flags & O_NONBLOCK)) ? \
MSG_DONTWAIT : 0;
- }
- else {
-
+ else
flags = 0;
- }
/*
* If there is data in the receive queue, flush it,
* and consider this an abort. Otherwise consider
@@ -416,11 +375,9 @@ static int _sdp_inet_release(struct sock
* abort.
*/
result = _sdp_inet_abort(conn);
- if (0 > result) {
-
+ if (0 > result)
sdp_dbg_warn(conn, "Error <%d> while aborting socket",
result);
- }
goto done;
}
@@ -429,7 +386,6 @@ static int _sdp_inet_release(struct sock
*/
result = _sdp_inet_disconnect(conn);
if (0 > result) {
-
sdp_dbg_warn(conn, "Error <%d> while disconnecting socket",
result);
goto done;
@@ -446,7 +402,6 @@ static int _sdp_inet_release(struct sock
*/
if (sock_flag(sk, SOCK_LINGER)
&& !(PF_EXITING & current->flags)) {
-
DECLARE_WAITQUEUE(wait, current);
timeout = sk->sk_lingertime;
@@ -455,15 +410,12 @@ static int _sdp_inet_release(struct sock
while (0 < timeout &&
0 == (SDP_ST_MASK_CLOSED & conn->istate)) {
-
SDP_CONN_UNLOCK(conn);
timeout = schedule_timeout(timeout);
SDP_CONN_LOCK(conn);
- if (signal_pending(current)) {
-
+ if (signal_pending(current))
break;
- }
}
set_current_state(TASK_RUNNING);
@@ -487,14 +439,9 @@ static int _sdp_inet_release(struct sock
} /* if (blocking) */
done:
- if (0 < (SDP_ST_MASK_CLOSED & conn->istate)) {
- /*
- * pass
- */
- }
- else {
+ if (0 < (SDP_ST_MASK_CLOSED & conn->istate))
+ do {} while(0); /* pass */
- }
/*
* finally drop socket reference. (socket API reference)
*/
@@ -528,16 +475,12 @@ static int _sdp_inet_bind(struct socket
sdp_dbg_ctrl(conn, "BIND: family <%d> addr <%08x:%04x>",
addr->sin_family, addr->sin_addr.s_addr, addr->sin_port);
- if (size < sizeof(struct sockaddr_in)) {
-
+ if (size < sizeof(struct sockaddr_in))
return -EINVAL;
- }
if (_proto_family != addr->sin_family &&
- AF_INET != addr->sin_family && AF_UNSPEC != addr->sin_family) {
-
+ AF_INET != addr->sin_family && AF_UNSPEC != addr->sin_family)
return -EAFNOSUPPORT;
- }
/*
* Basically we're OK with INADDR_ANY or a local interface
* (TODO: loopback)
@@ -551,41 +494,33 @@ static int _sdp_inet_bind(struct socket
if (inet_sk(sk)->freebind == 0 &&
RTN_LOCAL != addr_result &&
RTN_MULTICAST != addr_result &&
- RTN_BROADCAST != addr_result) {
-
+ RTN_BROADCAST != addr_result)
return -EADDRNOTAVAIL;
- }
}
/*
* check bind permission for low ports.
*/
bind_port = ntohs(addr->sin_port);
if (0 < bind_port &&
- bind_port < PROT_SOCK && 0 == capable(CAP_NET_BIND_SERVICE)) {
-
+ bind_port < PROT_SOCK && 0 == capable(CAP_NET_BIND_SERVICE))
return -EACCES;
- }
/*
* socket checks.
*/
SDP_CONN_LOCK(conn);
if (SDP_SOCK_ST_CLOSED != conn->istate || 0 < conn->src_port) {
-
result = -EINVAL;
goto done;
}
conn->src_addr = ntohl(addr->sin_addr.s_addr);
- if (RTN_MULTICAST == addr_result || RTN_BROADCAST == addr_result) {
-
+ if (RTN_MULTICAST == addr_result || RTN_BROADCAST == addr_result)
conn->src_addr = 0;
- }
result = sdp_inet_port_get(conn, bind_port);
if (0 > result) {
-
sdp_dbg_warn(conn, "Error <%d> getting port during bind",
result);
@@ -594,15 +529,11 @@ static int _sdp_inet_bind(struct socket
goto done;
}
- if (INADDR_ANY != conn->src_addr) {
-
+ if (INADDR_ANY != conn->src_addr)
sk->sk_userlocks |= SOCK_BINDADDR_LOCK;
- }
-
- if (0 < bind_port) {
+ if (0 < bind_port)
sk->sk_userlocks |= SOCK_BINDADDR_LOCK;
- }
inet_sk(sk)->rcv_saddr = htonl(conn->src_addr);
inet_sk(sk)->saddr = htonl(conn->src_addr);
@@ -641,25 +572,19 @@ static int _sdp_inet_connect(struct sock
sdp_dbg_ctrl(conn, "CONNECT: family <%d> addr <%08x:%04x>",
addr->sin_family, addr->sin_addr.s_addr, addr->sin_port);
- if (size < sizeof(struct sockaddr_in)) {
-
+ if (size < sizeof(struct sockaddr_in))
return -EINVAL;
- }
if (_proto_family != addr->sin_family &&
- AF_INET != addr->sin_family && AF_UNSPEC != addr->sin_family) {
-
+ AF_INET != addr->sin_family && AF_UNSPEC != addr->sin_family)
return -EAFNOSUPPORT;
- }
if (MULTICAST(addr->sin_addr.s_addr) ||
BADCLASS(addr->sin_addr.s_addr) ||
ZERONET(addr->sin_addr.s_addr) ||
LOCAL_MCAST(addr->sin_addr.s_addr) ||
- INADDR_ANY == addr->sin_addr.s_addr) {
-
+ INADDR_ANY == addr->sin_addr.s_addr)
return -EINVAL;
- }
/*
* lock socket
*/
@@ -667,18 +592,14 @@ static int _sdp_inet_connect(struct sock
switch (sock->state) {
case SS_UNCONNECTED:
-
if (0 == (SDP_ST_MASK_CLOSED & conn->istate)) {
-
result = -EISCONN;
goto done;
}
if (0 == conn->src_port) {
-
result = sdp_inet_port_get(conn, 0);
if (0 > result) {
-
sdp_dbg_warn(conn, "Error <%d> getting port",
result);
goto done;
@@ -706,7 +627,6 @@ static int _sdp_inet_connect(struct sock
*/
result = sdp_cm_connect(conn);
if (0 > result) {
-
sdp_dbg_warn(conn, "Error <%d> initiating connect",
result);
@@ -727,15 +647,12 @@ static int _sdp_inet_connect(struct sock
result = -EINPROGRESS;
break;
case SS_CONNECTING:
-
result = -EALREADY;
break;
case SS_CONNECTED:
-
result = -EISCONN;
goto done;
default:
-
result = -EINVAL;
goto done;
}
@@ -785,18 +702,15 @@ static int _sdp_inet_connect(struct sock
break;
case SDP_SOCK_ST_ESTABLISHED:
case SDP_SOCK_ST_CLOSE:
-
sock->state = SS_CONNECTED;
result = 0;
break;
case SDP_SOCK_ST_CLOSED:
case SDP_SOCK_ST_ERROR:
-
result = SDP_CONN_ERROR(conn) ? : -ECONNABORTED;
sock->state = SS_UNCONNECTED;
break;
default:
-
sdp_dbg_warn(conn, "Unexpected state after connect. <%08x>",
sock->state);
break;
@@ -832,26 +746,21 @@ static int _sdp_inet_listen(struct socke
if (SS_UNCONNECTED != sock->state ||
(SDP_SOCK_ST_CLOSED != conn->istate &&
SDP_SOCK_ST_LISTEN != conn->istate)) {
-
result = -EINVAL;
goto done;
}
if (SDP_SOCK_ST_LISTEN != conn->istate) {
-
result = sdp_inet_listen_start(conn);
if (0 > result) {
-
sdp_dbg_warn(conn, "Error <%d> starting listen",
result);
goto done;
}
if (0 == conn->src_port) {
-
result = sdp_inet_port_get(conn, 0);
if (0 > result) {
-
sdp_dbg_warn(conn, "Error <%d> getting port",
result);
goto done;
@@ -901,7 +810,6 @@ static int _sdp_inet_accept(struct socke
SDP_CONN_LOCK(listen_conn);
if (SDP_SOCK_ST_LISTEN != listen_conn->istate) {
-
result = -EINVAL;
goto listen_done;
}
@@ -917,7 +825,6 @@ static int _sdp_inet_accept(struct socke
*/
accept_conn = sdp_inet_accept_q_get(listen_conn);
if (NULL == accept_conn) {
-
DECLARE_WAITQUEUE(wait, current);
add_wait_queue(listen_sk->sk_sleep, &wait);
set_current_state(TASK_INTERRUPTIBLE);
@@ -925,15 +832,12 @@ static int _sdp_inet_accept(struct socke
while (0 < timeout &&
SDP_SOCK_ST_LISTEN == listen_conn->istate &&
0 == listen_conn->backlog_cnt) {
-
SDP_CONN_UNLOCK(listen_conn);
timeout = schedule_timeout(timeout);
SDP_CONN_LOCK(listen_conn);
- if (signal_pending(current)) {
-
+ if (signal_pending(current))
break;
- }
}
set_current_state(TASK_RUNNING);
@@ -944,30 +848,20 @@ static int _sdp_inet_accept(struct socke
if (0 == listen_conn->backlog_cnt) {
result = 0;
- if (SDP_SOCK_ST_LISTEN !=
- listen_conn->istate) {
-
+ if (SDP_SOCK_ST_LISTEN != listen_conn->istate)
result = -EINVAL;
- }
- if (signal_pending(current)) {
-
+ if (signal_pending(current))
result = sock_intr_errno(timeout);
- }
- if (0 == timeout) {
-
+ if (0 == timeout)
result = -EAGAIN;
- }
goto listen_done;
}
- }
- else {
-
+ } else {
accept_sk = accept_conn->sk;
switch (accept_conn->istate) {
case SDP_SOCK_ST_ACCEPTED:
-
sock_graft(accept_sk, accept_sock);
accept_conn->pid = current->pid;
@@ -979,7 +873,6 @@ static int _sdp_inet_accept(struct socke
break;
case SDP_SOCK_ST_ACCEPTING:
-
sock_graft(accept_sk, accept_sock);
accept_conn->pid = current->pid;
@@ -994,7 +887,6 @@ static int _sdp_inet_accept(struct socke
break;
case SDP_SOCK_ST_CLOSE:
-
sock_graft(accept_sk, accept_sock);
accept_conn->pid = current->pid;
@@ -1004,7 +896,6 @@ static int _sdp_inet_accept(struct socke
break;
default:
-
sdp_dbg_warn(accept_conn, "bad accept state");
case SDP_SOCK_ST_CLOSED:
@@ -1026,7 +917,7 @@ static int _sdp_inet_accept(struct socke
break;
}
- if (NULL != accept_conn) {
+ if (NULL != accept_conn)
/*
* Connections returned from the AcceptQueue
* are holding their lock, before returning
@@ -1035,7 +926,6 @@ static int _sdp_inet_accept(struct socke
*/
/* AcceptQueueGet */
SDP_CONN_UNLOCK(accept_conn);
- }
}
}
@@ -1078,21 +968,15 @@ static int _sdp_inet_getname(struct sock
conn->dst_addr, conn->dst_port);
addr->sin_family = _proto_family;
- if (0 < peer) {
-
+ if (0 < peer)
if (0 < htons(conn->dst_port) &&
0 == (SDP_ST_MASK_CLOSED & conn->istate)) {
addr->sin_port = htons(conn->dst_port);
addr->sin_addr.s_addr = htonl(conn->dst_addr);
- }
- else {
-
+ } else
return -ENOTCONN;
- }
- }
else {
-
addr->sin_port = htons(conn->src_port);
addr->sin_addr.s_addr = htonl(conn->src_addr);
}
@@ -1136,17 +1020,13 @@ static unsigned int _sdp_inet_poll(struc
* no locking, should be safe as is.
*/
switch (conn->istate) {
-
case SDP_SOCK_ST_LISTEN:
-
mask |= (0 < conn->backlog_cnt) ? (POLLIN | POLLRDNORM) : 0;
break;
case SDP_SOCK_ST_ERROR:
-
mask |= POLLERR;
break;
case SDP_SOCK_ST_CLOSED:
-
mask |= POLLHUP;
break;
case SDP_SOCK_ST_ESTABLISHED:
@@ -1158,19 +1038,16 @@ static unsigned int _sdp_inet_poll(struc
* recv EOF _and_ recv data
*/
if (!(conn->byte_strm < sk->sk_rcvlowat) ||
- 0 < (RCV_SHUTDOWN & conn->shutdown)) {
+ 0 < (RCV_SHUTDOWN & conn->shutdown))
mask |= POLLIN | POLLRDNORM;
- }
/*
* send EOF _or_ send data space.
* (Some poll() Linux documentation says that POLLHUP is
* incompatible with the POLLOUT/POLLWR flags)
*/
- if (0 < (SEND_SHUTDOWN & conn->shutdown)) {
-
+ if (0 < (SEND_SHUTDOWN & conn->shutdown))
mask |= POLLHUP;
- }
else {
/*
* avoid race by setting flags, and only clearing
@@ -1182,7 +1059,6 @@ static unsigned int _sdp_inet_poll(struc
set_bit(SOCK_NOSPACE, &sock->flags);
if (0 < __sdp_inet_writable(conn)) {
-
mask |= POLLOUT | POLLWRNORM;
clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags);
@@ -1190,10 +1066,8 @@ static unsigned int _sdp_inet_poll(struc
}
}
- if (0 < conn->rcv_urg_cnt) {
-
+ if (0 < conn->rcv_urg_cnt)
mask |= POLLPRI;
- }
}
sdp_dbg_data(conn, "POLL: mask <%08x> flags <%08lx> <%d:%d:%d>",
@@ -1231,12 +1105,9 @@ static int _sdp_inet_ioctl(struct socket
* standard INET IOCTLs
*/
case SIOCGSTAMP:
- if (0 == sk->sk_stamp.tv_sec) {
-
+ if (0 == sk->sk_stamp.tv_sec)
result = -ENOENT;
- }
else {
-
result = copy_to_user((void __user *)arg,
&sk->sk_stamp,
sizeof(struct timeval));
@@ -1250,7 +1121,6 @@ static int _sdp_inet_ioctl(struct socket
case SIOCADDRT:
case SIOCDELRT:
case SIOCRTMSG:
-
result = ip_rt_ioctl(cmd, (void __user *)arg);
break;
/*
@@ -1279,14 +1149,12 @@ static int _sdp_inet_ioctl(struct socket
case SIOCSIFPFLAGS:
case SIOCGIFPFLAGS:
case SIOCSIFFLAGS:
-
result = devinet_ioctl(cmd, (void __user *)arg);
break;
/*
* stadard INET STREAM IOCTLs
*/
case SIOCINQ:
-
SDP_CONN_LOCK(conn);
if (SDP_SOCK_ST_LISTEN != conn->istate) {
@@ -1295,45 +1163,33 @@ static int _sdp_inet_ioctl(struct socket
*/
value = conn->byte_strm;
result = put_user(value, (int __user *) arg);
- }
- else {
-
+ } else
result = -EINVAL;
- }
SDP_CONN_UNLOCK(conn);
break;
case SIOCOUTQ:
-
SDP_CONN_LOCK(conn);
if (SDP_SOCK_ST_LISTEN != conn->istate) {
-
value = conn->send_qud;
result = put_user(value, (int __user *) arg);
- }
- else {
-
+ } else
result = -EINVAL;
- }
SDP_CONN_UNLOCK(conn);
break;
case SIOCATMARK:
-
SDP_CONN_LOCK(conn);
value = 0;
if (0 < conn->rcv_urg_cnt) {
-
buff = sdp_buff_q_look_head(&conn->recv_pool);
if (NULL != buff &&
0 < (SDP_BUFF_F_OOB_PRES & buff->flags) &&
- 1 == (buff->tail - buff->data)) {
-
+ 1 == (buff->tail - buff->data))
value = 1;
- }
}
result = put_user(value, (int __user *) arg);
@@ -1341,7 +1197,6 @@ static int _sdp_inet_ioctl(struct socket
SDP_CONN_UNLOCK(conn);
break;
default:
-
result = dev_ioctl(cmd, (void __user *)arg);
break;
}
@@ -1370,37 +1225,28 @@ static int _sdp_inet_setopt(struct socke
sdp_dbg_ctrl(conn, "SETSOCKOPT: level <%d> option <%d>",
level, optname);
- if (SOL_TCP != level && SOL_SDP != level) {
-
+ if (SOL_TCP != level && SOL_SDP != level)
return 0;
- }
-
- if (optlen < sizeof(int)) {
+ if (optlen < sizeof(int))
return -EINVAL;
- }
-
- if (get_user(value, (int __user *)optval)) {
+ if (get_user(value, (int __user *)optval))
return -EFAULT;
- }
SDP_CONN_LOCK(conn);
switch (optname) {
case TCP_NODELAY:
-
conn->nodelay = (0 == value) ? 0 : 1;
if (0 < conn->nodelay) {
-
result = sdp_send_flush(conn);
SDP_EXPECT(!(0 > result));
}
break;
case SDP_ZCOPY_THRSH:
-
conn->src_zthresh = value;
conn->snk_zthresh =
((value >
@@ -1409,11 +1255,9 @@ static int _sdp_inet_setopt(struct socke
SDP_MSG_HDR_SIZE));
break;
case SDP_ZCOPY_THRSH_SRC:
-
conn->src_zthresh = value;
break;
case SDP_ZCOPY_THRSH_SNK:
-
conn->snk_zthresh =
((value >
(conn->recv_size -
@@ -1421,11 +1265,9 @@ static int _sdp_inet_setopt(struct socke
SDP_MSG_HDR_SIZE));
break;
case SDP_UNBIND:
-
result = sdp_inet_port_put(conn);
break;
default:
-
sdp_warn("SETSOCKOPT unimplemented option <%d:%d> conn <%d>.",
level, optname, conn->hashent);
break;
@@ -1457,48 +1299,36 @@ static int _sdp_inet_getopt(struct socke
sdp_dbg_ctrl(conn, "GETSOCKOPT: level <%d> option <%d>",
level, optname);
- if (SOL_TCP != level && SOL_SDP != level) {
-
+ if (SOL_TCP != level && SOL_SDP != level)
return 0;
- }
-
- if (get_user(len, optlen)) {
+ if (get_user(len, optlen))
return -EFAULT;
- }
len = min(len, (int)sizeof(int));
- if (len < 0) {
-
+ if (len < 0)
return -EINVAL;
- }
SDP_CONN_LOCK(conn);
switch (optname) {
case TCP_NODELAY:
-
value = (1 == conn->nodelay);
break;
case TCP_MAXSEG:
-
value = max(conn->send_size, (u16)1);
break;
case SDP_ZCOPY_THRSH:
-
value = ((conn->src_zthresh == conn->snk_zthresh) ?
conn->snk_zthresh : -EPROTO);
break;
case SDP_ZCOPY_THRSH_SRC:
-
value = conn->src_zthresh;
break;
case SDP_ZCOPY_THRSH_SNK:
-
value = conn->snk_zthresh;
break;
default:
-
sdp_warn("GETSOCKOPT unimplemented option <%d:%d> conn <%d>",
level, optname, conn->hashent);
break;
@@ -1506,15 +1336,11 @@ static int _sdp_inet_getopt(struct socke
SDP_CONN_UNLOCK(conn);
- if (put_user(len, optlen)) {
-
+ if (put_user(len, optlen))
return -EFAULT;
- }
-
- if (copy_to_user(optval, &value, len)) {
+ if (copy_to_user(optval, &value, len))
return -EFAULT;
- }
return 0;
} /* _sdp_inet_getopt */
@@ -1537,14 +1363,10 @@ static int _sdp_inet_shutdown(struct soc
* 1 - send shutdown
* 2 - send/recv shutdown.
*/
- if (0 > flag || 2 < flag) {
-
+ if (0 > flag || 2 < flag)
return -EINVAL;
- }
- else {
-
+ else
flag++; /* match shutdown mask. */
- }
SDP_CONN_LOCK(conn);
@@ -1552,7 +1374,6 @@ static int _sdp_inet_shutdown(struct soc
switch (conn->istate) {
case SDP_SOCK_ST_CLOSED:
-
result = -ENOTCONN;
break;
case SDP_SOCK_ST_LISTEN:
@@ -1560,41 +1381,30 @@ static int _sdp_inet_shutdown(struct soc
* Send shutdown is benign.
*/
if (0 < (RCV_SHUTDOWN & flag)) {
-
result = sdp_inet_listen_stop(conn);
- if (0 > result) {
-
+ if (0 > result)
sdp_dbg_warn(conn, "listen stop error <%d>",
result);
- }
}
break;
case SDP_SOCK_ST_ERROR:
-
result = SDP_CONN_ERROR(conn);
result = (result < 0) ? result : -ECONNABORTED;
break;
case SDP_SOCK_ST_ACCEPTED:
case SDP_SOCK_ST_CONNECT:
-
result = _sdp_inet_abort(conn);
- if (0 > result) {
-
+ if (0 > result)
sdp_dbg_warn(conn, "Error <%d> aborting connection",
result);
- }
-
break;
case SDP_SOCK_ST_ESTABLISHED:
case SDP_SOCK_ST_CLOSE:
-
result = _sdp_inet_disconnect(conn);
- if (0 > result) {
-
+ if (0 > result)
sdp_dbg_warn(conn, "Error <%d> disconnecting conn",
result);
- }
break;
case SDP_SOCK_ST_DISCONNECT:
@@ -1604,7 +1414,6 @@ static int _sdp_inet_shutdown(struct soc
*/
break;
case SDP_SOCK_ST_ACCEPTING:
-
sdp_dbg_warn(conn, "connection state error");
conn->istate = SDP_SOCK_ST_ERROR;
@@ -1613,7 +1422,6 @@ static int _sdp_inet_shutdown(struct soc
break;
default:
-
sdp_warn("Unknown socket state. conn <%d> state <%04x:%04x>",
conn->hashent, conn->istate, conn->state);
@@ -1622,12 +1430,10 @@ static int _sdp_inet_shutdown(struct soc
result = -EFAULT;
}
- if (0 > result) {
+ if (0 > result)
sdp_inet_wake_generic(sock->sk);
- }
- else {
+ else
sdp_inet_wake_error(sock->sk);
- }
SDP_CONN_UNLOCK(conn);
return result;
@@ -1671,7 +1477,6 @@ static int _sdp_inet_create(struct socke
if (SOCK_STREAM != sock->type ||
(IPPROTO_IP != protocol && IPPROTO_TCP != protocol)) {
-
sdp_dbg_warn(NULL, "SOCKET: unsupported type/proto. <%d:%d>",
sock->type, protocol);
@@ -1680,7 +1485,6 @@ static int _sdp_inet_create(struct socke
conn = sdp_conn_alloc(GFP_KERNEL);
if (NULL == conn) {
-
sdp_dbg_warn(conn, "SOCKET: failed to create socekt <%d:%d>",
sock->type, protocol);
return -ENOMEM;
@@ -1731,7 +1535,6 @@ static int __init sdp_init(void)
*/
result = sdp_main_proc_init();
if (0 > result) {
-
sdp_warn("INIT: Error <%d> creating proc entries.", result);
goto error_proc;
}
@@ -1740,7 +1543,6 @@ static int __init sdp_init(void)
*/
result = sdp_main_advt_init();
if (0 > result) {
-
sdp_warn("INIT: Error <%d> initializing advertisments",
result);
goto error_advt;
@@ -1750,7 +1552,6 @@ static int __init sdp_init(void)
*/
result = sdp_link_addr_init();
if (0 > result) {
-
sdp_warn("INIT: Error <%d> initializing link",
result);
goto error_link;
@@ -1763,7 +1564,6 @@ static int __init sdp_init(void)
_alloc_inc,
_free_mark);
if (0 > result) {
-
sdp_warn("INIT: Error <%d> initializing buffer pool.", result);
goto error_buff;
}
@@ -1778,7 +1578,6 @@ static int __init sdp_init(void)
_send_buff_max,
_send_usig_max);
if (0 > result) {
-
sdp_warn("INIT: Error <%d> initializing connection table.",
result);
goto error_conn;
@@ -1790,7 +1589,6 @@ static int __init sdp_init(void)
result = sock_register(&_sdp_proto);
if (result < 0) {
-
sdp_warn("INIT: Error <%d> registering protocol family <%d>",
result, _sdp_proto.family);
goto error_sock;
More information about the general
mailing list