Skip to content

Commit e27dfce

Browse files
Jianjun Kongdavem330
authored andcommitted
af_unix: clean up net/unix/af_unix.c garbage.c sysctl_net_unix.c
clean up net/unix/af_unix.c garbage.c sysctl_net_unix.c Signed-off-by: Jianjun Kong <jianjun@zeuux.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c37ccc0 commit e27dfce

File tree

3 files changed

+42
-44
lines changed

3 files changed

+42
-44
lines changed

net/unix/af_unix.c

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static int unix_mkname(struct sockaddr_un * sunaddr, int len, unsigned *hashp)
211211
* we are guaranteed that it is a valid memory location in our
212212
* kernel address buffer.
213213
*/
214-
((char *)sunaddr)[len]=0;
214+
((char *)sunaddr)[len] = 0;
215215
len = strlen(sunaddr->sun_path)+1+sizeof(short);
216216
return len;
217217
}
@@ -392,9 +392,9 @@ static int unix_release_sock (struct sock *sk, int embrion)
392392

393393
wake_up_interruptible_all(&u->peer_wait);
394394

395-
skpair=unix_peer(sk);
395+
skpair = unix_peer(sk);
396396

397-
if (skpair!=NULL) {
397+
if (skpair != NULL) {
398398
if (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) {
399399
unix_state_lock(skpair);
400400
/* No more writes */
@@ -414,7 +414,7 @@ static int unix_release_sock (struct sock *sk, int embrion)
414414
/* Try to flush out this socket. Throw out buffers at least */
415415

416416
while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
417-
if (state==TCP_LISTEN)
417+
if (state == TCP_LISTEN)
418418
unix_release_sock(skb->sk, 1);
419419
/* passed fds are erased in the kfree_skb hook */
420420
kfree_skb(skb);
@@ -630,7 +630,7 @@ static int unix_create(struct net *net, struct socket *sock, int protocol)
630630
* nothing uses it.
631631
*/
632632
case SOCK_RAW:
633-
sock->type=SOCK_DGRAM;
633+
sock->type = SOCK_DGRAM;
634634
case SOCK_DGRAM:
635635
sock->ops = &unix_dgram_ops;
636636
break;
@@ -736,14 +736,14 @@ static struct sock *unix_find_other(struct net *net,
736736

737737
path_put(&path);
738738

739-
err=-EPROTOTYPE;
739+
err = -EPROTOTYPE;
740740
if (u->sk_type != type) {
741741
sock_put(u);
742742
goto fail;
743743
}
744744
} else {
745745
err = -ECONNREFUSED;
746-
u=unix_find_socket_byname(net, sunname, len, type, hash);
746+
u = unix_find_socket_byname(net, sunname, len, type, hash);
747747
if (u) {
748748
struct dentry *dentry;
749749
dentry = unix_sk(u)->dentry;
@@ -757,7 +757,7 @@ static struct sock *unix_find_other(struct net *net,
757757
put_fail:
758758
path_put(&path);
759759
fail:
760-
*error=err;
760+
*error = err;
761761
return NULL;
762762
}
763763

@@ -767,7 +767,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
767767
struct sock *sk = sock->sk;
768768
struct net *net = sock_net(sk);
769769
struct unix_sock *u = unix_sk(sk);
770-
struct sockaddr_un *sunaddr=(struct sockaddr_un *)uaddr;
770+
struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr;
771771
struct dentry * dentry = NULL;
772772
struct nameidata nd;
773773
int err;
@@ -779,7 +779,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
779779
if (sunaddr->sun_family != AF_UNIX)
780780
goto out;
781781

782-
if (addr_len==sizeof(short)) {
782+
if (addr_len == sizeof(short)) {
783783
err = unix_autobind(sock);
784784
goto out;
785785
}
@@ -875,8 +875,8 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
875875
mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
876876
path_put(&nd.path);
877877
out_mknod_parent:
878-
if (err==-EEXIST)
879-
err=-EADDRINUSE;
878+
if (err == -EEXIST)
879+
err = -EADDRINUSE;
880880
unix_release_addr(addr);
881881
goto out_up;
882882
}
@@ -911,7 +911,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
911911
{
912912
struct sock *sk = sock->sk;
913913
struct net *net = sock_net(sk);
914-
struct sockaddr_un *sunaddr=(struct sockaddr_un*)addr;
914+
struct sockaddr_un *sunaddr = (struct sockaddr_un *)addr;
915915
struct sock *other;
916916
unsigned hash;
917917
int err;
@@ -927,7 +927,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
927927
goto out;
928928

929929
restart:
930-
other=unix_find_other(net, sunaddr, alen, sock->type, hash, &err);
930+
other = unix_find_other(net, sunaddr, alen, sock->type, hash, &err);
931931
if (!other)
932932
goto out;
933933

@@ -961,14 +961,14 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
961961
*/
962962
if (unix_peer(sk)) {
963963
struct sock *old_peer = unix_peer(sk);
964-
unix_peer(sk)=other;
964+
unix_peer(sk) = other;
965965
unix_state_double_unlock(sk, other);
966966

967967
if (other != old_peer)
968968
unix_dgram_disconnected(sk, old_peer);
969969
sock_put(old_peer);
970970
} else {
971-
unix_peer(sk)=other;
971+
unix_peer(sk) = other;
972972
unix_state_double_unlock(sk, other);
973973
}
974974
return 0;
@@ -1004,7 +1004,7 @@ static long unix_wait_for_peer(struct sock *other, long timeo)
10041004
static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
10051005
int addr_len, int flags)
10061006
{
1007-
struct sockaddr_un *sunaddr=(struct sockaddr_un *)uaddr;
1007+
struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr;
10081008
struct sock *sk = sock->sk;
10091009
struct net *net = sock_net(sk);
10101010
struct unix_sock *u = unix_sk(sk), *newu, *otheru;
@@ -1179,13 +1179,13 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
11791179

11801180
static int unix_socketpair(struct socket *socka, struct socket *sockb)
11811181
{
1182-
struct sock *ska=socka->sk, *skb = sockb->sk;
1182+
struct sock *ska = socka->sk, *skb = sockb->sk;
11831183

11841184
/* Join our sockets back to back */
11851185
sock_hold(ska);
11861186
sock_hold(skb);
1187-
unix_peer(ska)=skb;
1188-
unix_peer(skb)=ska;
1187+
unix_peer(ska) = skb;
1188+
unix_peer(skb) = ska;
11891189
ska->sk_peercred.pid = skb->sk_peercred.pid = task_tgid_vnr(current);
11901190
ska->sk_peercred.uid = skb->sk_peercred.uid = current->euid;
11911191
ska->sk_peercred.gid = skb->sk_peercred.gid = current->egid;
@@ -1246,7 +1246,7 @@ static int unix_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_
12461246
{
12471247
struct sock *sk = sock->sk;
12481248
struct unix_sock *u;
1249-
struct sockaddr_un *sunaddr=(struct sockaddr_un *)uaddr;
1249+
struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr;
12501250
int err = 0;
12511251

12521252
if (peer) {
@@ -1323,7 +1323,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
13231323
struct sock *sk = sock->sk;
13241324
struct net *net = sock_net(sk);
13251325
struct unix_sock *u = unix_sk(sk);
1326-
struct sockaddr_un *sunaddr=msg->msg_name;
1326+
struct sockaddr_un *sunaddr = msg->msg_name;
13271327
struct sock *other = NULL;
13281328
int namelen = 0; /* fake GCC */
13291329
int err;
@@ -1364,7 +1364,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
13641364
goto out;
13651365

13661366
skb = sock_alloc_send_skb(sk, len, msg->msg_flags&MSG_DONTWAIT, &err);
1367-
if (skb==NULL)
1367+
if (skb == NULL)
13681368
goto out;
13691369

13701370
memcpy(UNIXCREDS(skb), &siocb->scm->creds, sizeof(struct ucred));
@@ -1387,7 +1387,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
13871387

13881388
other = unix_find_other(net, sunaddr, namelen, sk->sk_type,
13891389
hash, &err);
1390-
if (other==NULL)
1390+
if (other == NULL)
13911391
goto out_free;
13921392
}
13931393

@@ -1407,7 +1407,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
14071407
err = 0;
14081408
unix_state_lock(sk);
14091409
if (unix_peer(sk) == other) {
1410-
unix_peer(sk)=NULL;
1410+
unix_peer(sk) = NULL;
14111411
unix_state_unlock(sk);
14121412

14131413
unix_dgram_disconnected(sk, other);
@@ -1473,10 +1473,10 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
14731473
struct sock_iocb *siocb = kiocb_to_siocb(kiocb);
14741474
struct sock *sk = sock->sk;
14751475
struct sock *other = NULL;
1476-
struct sockaddr_un *sunaddr=msg->msg_name;
1476+
struct sockaddr_un *sunaddr = msg->msg_name;
14771477
int err,size;
14781478
struct sk_buff *skb;
1479-
int sent=0;
1479+
int sent = 0;
14801480
struct scm_cookie tmp_scm;
14811481

14821482
if (NULL == siocb->scm)
@@ -1523,9 +1523,9 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
15231523
* Grab a buffer
15241524
*/
15251525

1526-
skb=sock_alloc_send_skb(sk,size,msg->msg_flags&MSG_DONTWAIT, &err);
1526+
skb = sock_alloc_send_skb(sk,size,msg->msg_flags&MSG_DONTWAIT, &err);
15271527

1528-
if (skb==NULL)
1528+
if (skb == NULL)
15291529
goto out_err;
15301530

15311531
/*
@@ -1555,7 +1555,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
15551555
skb_queue_tail(&other->sk_receive_queue, skb);
15561556
unix_state_unlock(other);
15571557
other->sk_data_ready(other, size);
1558-
sent+=size;
1558+
sent += size;
15591559
}
15601560

15611561
scm_destroy(siocb->scm);
@@ -1734,7 +1734,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
17341734
struct scm_cookie tmp_scm;
17351735
struct sock *sk = sock->sk;
17361736
struct unix_sock *u = unix_sk(sk);
1737-
struct sockaddr_un *sunaddr=msg->msg_name;
1737+
struct sockaddr_un *sunaddr = msg->msg_name;
17381738
int copied = 0;
17391739
int check_creds = 0;
17401740
int target;
@@ -1772,7 +1772,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
17721772

17731773
unix_state_lock(sk);
17741774
skb = skb_dequeue(&sk->sk_receive_queue);
1775-
if (skb==NULL)
1775+
if (skb == NULL)
17761776
{
17771777
if (copied >= target)
17781778
goto unlock;
@@ -1884,7 +1884,7 @@ static int unix_shutdown(struct socket *sock, int mode)
18841884
if (mode) {
18851885
unix_state_lock(sk);
18861886
sk->sk_shutdown |= mode;
1887-
other=unix_peer(sk);
1887+
other = unix_peer(sk);
18881888
if (other)
18891889
sock_hold(other);
18901890
unix_state_unlock(sk);
@@ -1919,7 +1919,7 @@ static int unix_shutdown(struct socket *sock, int mode)
19191919
static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
19201920
{
19211921
struct sock *sk = sock->sk;
1922-
long amount=0;
1922+
long amount = 0;
19231923
int err;
19241924

19251925
switch(cmd)
@@ -1945,7 +1945,7 @@ static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
19451945
} else {
19461946
skb = skb_peek(&sk->sk_receive_queue);
19471947
if (skb)
1948-
amount=skb->len;
1948+
amount = skb->len;
19491949
}
19501950
spin_unlock(&sk->sk_receive_queue.lock);
19511951
err = put_user(amount, (int __user *)arg);
@@ -2077,6 +2077,7 @@ struct unix_iter_state {
20772077
struct seq_net_private p;
20782078
int i;
20792079
};
2080+
20802081
static struct sock *unix_seq_idx(struct seq_file *seq, loff_t pos)
20812082
{
20822083
struct unix_iter_state *iter = seq->private;
@@ -2093,7 +2094,6 @@ static struct sock *unix_seq_idx(struct seq_file *seq, loff_t pos)
20932094
return NULL;
20942095
}
20952096

2096-
20972097
static void *unix_seq_start(struct seq_file *seq, loff_t *pos)
20982098
__acquires(unix_table_lock)
20992099
{
@@ -2173,7 +2173,6 @@ static const struct seq_operations unix_seq_ops = {
21732173
.show = unix_seq_show,
21742174
};
21752175

2176-
21772176
static int unix_seq_open(struct inode *inode, struct file *file)
21782177
{
21792178
return seq_open_net(inode, file, &unix_seq_ops,

net/unix/garbage.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ static struct sock *unix_get_socket(struct file *filp)
104104
* Socket ?
105105
*/
106106
if (S_ISSOCK(inode->i_mode)) {
107-
struct socket * sock = SOCKET_I(inode);
108-
struct sock * s = sock->sk;
107+
struct socket *sock = SOCKET_I(inode);
108+
struct sock *s = sock->sk;
109109

110110
/*
111111
* PF_UNIX ?
@@ -124,7 +124,7 @@ static struct sock *unix_get_socket(struct file *filp)
124124
void unix_inflight(struct file *fp)
125125
{
126126
struct sock *s = unix_get_socket(fp);
127-
if(s) {
127+
if (s) {
128128
struct unix_sock *u = unix_sk(s);
129129
spin_lock(&unix_gc_lock);
130130
if (atomic_long_inc_return(&u->inflight) == 1) {
@@ -141,7 +141,7 @@ void unix_inflight(struct file *fp)
141141
void unix_notinflight(struct file *fp)
142142
{
143143
struct sock *s = unix_get_socket(fp);
144-
if(s) {
144+
if (s) {
145145
struct unix_sock *u = unix_sk(s);
146146
spin_lock(&unix_gc_lock);
147147
BUG_ON(list_empty(&u->link));
@@ -154,7 +154,7 @@ void unix_notinflight(struct file *fp)
154154

155155
static inline struct sk_buff *sock_queue_head(struct sock *sk)
156156
{
157-
return (struct sk_buff *) &sk->sk_receive_queue;
157+
return (struct sk_buff *)&sk->sk_receive_queue;
158158
}
159159

160160
#define receive_queue_for_each_skb(sk, next, skb) \
@@ -339,7 +339,7 @@ void unix_gc(void)
339339
*/
340340
skb_queue_head_init(&hitlist);
341341
list_for_each_entry(u, &gc_candidates, link)
342-
scan_children(&u->sk, inc_inflight, &hitlist);
342+
scan_children(&u->sk, inc_inflight, &hitlist);
343343

344344
spin_unlock(&unix_gc_lock);
345345

net/unix/sysctl_net_unix.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,3 @@ void unix_sysctl_unregister(struct net *net)
6161
unregister_sysctl_table(net->unx.ctl);
6262
kfree(table);
6363
}
64-

0 commit comments

Comments
 (0)