net: Cleanup of af_unix

This is a pure cleanup of net/unix/af_unix.c to meet current code
style standards

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Eric Dumazet
2008-11-16 22:58:44 -08:00
committed by David S. Miller
parent 1910299636
commit 6eba6a372b

View File

@@ -164,7 +164,7 @@ static inline int unix_our_peer(struct sock *sk, struct sock *osk)
static inline int unix_may_send(struct sock *sk, struct sock *osk) static inline int unix_may_send(struct sock *sk, struct sock *osk)
{ {
return (unix_peer(osk) == NULL || unix_our_peer(sk, osk)); return unix_peer(osk) == NULL || unix_our_peer(sk, osk);
} }
static inline int unix_recvq_full(struct sock const *sk) static inline int unix_recvq_full(struct sock const *sk)
@@ -295,8 +295,7 @@ static struct sock *unix_find_socket_byinode(struct net *net, struct inode *i)
if (!net_eq(sock_net(s), net)) if (!net_eq(sock_net(s), net))
continue; continue;
if(dentry && dentry->d_inode == i) if (dentry && dentry->d_inode == i) {
{
sock_hold(s); sock_hold(s);
goto found; goto found;
} }
@@ -354,7 +353,7 @@ static void unix_sock_destructor(struct sock *sk)
WARN_ON(!sk_unhashed(sk)); WARN_ON(!sk_unhashed(sk));
WARN_ON(sk->sk_socket); WARN_ON(sk->sk_socket);
if (!sock_flag(sk, SOCK_DEAD)) { if (!sock_flag(sk, SOCK_DEAD)) {
printk("Attempt to release alive unix socket: %p\n", sk); printk(KERN_DEBUG "Attempt to release alive unix socket: %p\n", sk);
return; return;
} }
@@ -363,7 +362,8 @@ static void unix_sock_destructor(struct sock *sk)
atomic_dec(&unix_nr_socks); atomic_dec(&unix_nr_socks);
#ifdef UNIX_REFCNT_DEBUG #ifdef UNIX_REFCNT_DEBUG
printk(KERN_DEBUG "UNIX %p is destroyed, %d are still alive.\n", sk, atomic_read(&unix_nr_socks)); printk(KERN_DEBUG "UNIX %p is destroyed, %d are still alive.\n", sk,
atomic_read(&unix_nr_socks));
#endif #endif
} }
@@ -1515,8 +1515,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
if (sk->sk_shutdown & SEND_SHUTDOWN) if (sk->sk_shutdown & SEND_SHUTDOWN)
goto pipe_err; goto pipe_err;
while(sent < len) while (sent < len) {
{
/* /*
* Optimisation for the fact that under 0.01% of X * Optimisation for the fact that under 0.01% of X
* messages typically need breaking up. * messages typically need breaking up.
@@ -1535,7 +1534,8 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
* Grab a buffer * Grab a buffer
*/ */
skb = sock_alloc_send_skb(sk,size,msg->msg_flags&MSG_DONTWAIT, &err); skb = sock_alloc_send_skb(sk, size, msg->msg_flags&MSG_DONTWAIT,
&err);
if (skb == NULL) if (skb == NULL)
goto out_err; goto out_err;
@@ -1558,7 +1558,8 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
} }
} }
if ((err = memcpy_fromiovec(skb_put(skb,size), msg->msg_iov, size)) != 0) { err = memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size);
if (err) {
kfree_skb(skb); kfree_skb(skb);
goto out_err; goto out_err;
} }
@@ -1675,13 +1676,10 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
siocb->scm->creds = *UNIXCREDS(skb); siocb->scm->creds = *UNIXCREDS(skb);
unix_set_secdata(siocb->scm, skb); unix_set_secdata(siocb->scm, skb);
if (!(flags & MSG_PEEK)) if (!(flags & MSG_PEEK)) {
{
if (UNIXCB(skb).fp) if (UNIXCB(skb).fp)
unix_detach_fds(siocb->scm, skb); unix_detach_fds(siocb->scm, skb);
} } else {
else
{
/* It is questionable: on PEEK we could: /* It is questionable: on PEEK we could:
- do not return fds - good, but too simple 8) - do not return fds - good, but too simple 8)
- return fds, and do not return them on read (old strategy, - return fds, and do not return them on read (old strategy,
@@ -1782,15 +1780,13 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
mutex_lock(&u->readlock); mutex_lock(&u->readlock);
do do {
{
int chunk; int chunk;
struct sk_buff *skb; struct sk_buff *skb;
unix_state_lock(sk); unix_state_lock(sk);
skb = skb_dequeue(&sk->sk_receive_queue); skb = skb_dequeue(&sk->sk_receive_queue);
if (skb == NULL) if (skb == NULL) {
{
if (copied >= target) if (copied >= target)
goto unlock; goto unlock;
@@ -1798,7 +1794,8 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
* POSIX 1003.1g mandates this order. * POSIX 1003.1g mandates this order.
*/ */
if ((err = sock_error(sk)) != 0) err = sock_error(sk);
if (err)
goto unlock; goto unlock;
if (sk->sk_shutdown & RCV_SHUTDOWN) if (sk->sk_shutdown & RCV_SHUTDOWN)
goto unlock; goto unlock;
@@ -1825,7 +1822,8 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
if (check_creds) { if (check_creds) {
/* Never glue messages from different writers */ /* Never glue messages from different writers */
if (memcmp(UNIXCREDS(skb), &siocb->scm->creds, sizeof(siocb->scm->creds)) != 0) { if (memcmp(UNIXCREDS(skb), &siocb->scm->creds,
sizeof(siocb->scm->creds)) != 0) {
skb_queue_head(&sk->sk_receive_queue, skb); skb_queue_head(&sk->sk_receive_queue, skb);
break; break;
} }
@@ -1836,8 +1834,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
} }
/* Copy address just once */ /* Copy address just once */
if (sunaddr) if (sunaddr) {
{
unix_copy_addr(msg, skb->sk); unix_copy_addr(msg, skb->sk);
sunaddr = NULL; sunaddr = NULL;
} }
@@ -1853,16 +1850,14 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
size -= chunk; size -= chunk;
/* Mark read part of skb as used */ /* Mark read part of skb as used */
if (!(flags & MSG_PEEK)) if (!(flags & MSG_PEEK)) {
{
skb_pull(skb, chunk); skb_pull(skb, chunk);
if (UNIXCB(skb).fp) if (UNIXCB(skb).fp)
unix_detach_fds(siocb->scm, skb); unix_detach_fds(siocb->scm, skb);
/* put the skb back if we didn't use it up.. */ /* put the skb back if we didn't use it up.. */
if (skb->len) if (skb->len) {
{
skb_queue_head(&sk->sk_receive_queue, skb); skb_queue_head(&sk->sk_receive_queue, skb);
break; break;
} }
@@ -1871,9 +1866,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
if (siocb->scm->fp) if (siocb->scm->fp)
break; break;
} } else {
else
{
/* It is questionable, see note in unix_dgram_recvmsg. /* It is questionable, see note in unix_dgram_recvmsg.
*/ */
if (UNIXCB(skb).fp) if (UNIXCB(skb).fp)
@@ -1939,8 +1932,7 @@ static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
long amount = 0; long amount = 0;
int err; int err;
switch(cmd) switch (cmd) {
{
case SIOCOUTQ: case SIOCOUTQ:
amount = atomic_read(&sk->sk_wmem_alloc); amount = atomic_read(&sk->sk_wmem_alloc);
err = put_user(amount, (int __user *)arg); err = put_user(amount, (int __user *)arg);
@@ -1998,7 +1990,8 @@ static unsigned int unix_poll(struct file * file, struct socket *sock, poll_tabl
mask |= POLLIN | POLLRDNORM; mask |= POLLIN | POLLRDNORM;
/* Connection-based need to check for termination and startup */ /* Connection-based need to check for termination and startup */
if ((sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) && sk->sk_state == TCP_CLOSE) if ((sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) &&
sk->sk_state == TCP_CLOSE)
mask |= POLLHUP; mask |= POLLHUP;
/* /*