aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/svcsock.c
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2012-08-13 17:46:17 -0400
committerJ. Bruce Fields <bfields@redhat.com>2012-08-21 14:08:40 -0400
commit72c3537607e42928f13691d59579ec840014b19e (patch)
tree6bd4f6888111ea7edb8c99880f78e083b8b0980a /net/sunrpc/svcsock.c
parent719f8bcc883e7992615f4d5625922e24995e2d98 (diff)
svcrpc: standardize svc_setup_socket return convention
Use the kernel-standard ptr-or-error return convention instead of passing a pointer to the error. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'net/sunrpc/svcsock.c')
-rw-r--r--net/sunrpc/svcsock.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 998aa8c1807c..d028b51a69ad 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -59,7 +59,7 @@
59 59
60 60
61static struct svc_sock *svc_setup_socket(struct svc_serv *, struct socket *, 61static struct svc_sock *svc_setup_socket(struct svc_serv *, struct socket *,
62 int *errp, int flags); 62 int flags);
63static void svc_udp_data_ready(struct sock *, int); 63static void svc_udp_data_ready(struct sock *, int);
64static int svc_udp_recvfrom(struct svc_rqst *); 64static int svc_udp_recvfrom(struct svc_rqst *);
65static int svc_udp_sendto(struct svc_rqst *); 65static int svc_udp_sendto(struct svc_rqst *);
@@ -900,8 +900,9 @@ static struct svc_xprt *svc_tcp_accept(struct svc_xprt *xprt)
900 */ 900 */
901 newsock->sk->sk_sndtimeo = HZ*30; 901 newsock->sk->sk_sndtimeo = HZ*30;
902 902
903 if (!(newsvsk = svc_setup_socket(serv, newsock, &err, 903 newsvsk = svc_setup_socket(serv, newsock,
904 (SVC_SOCK_ANONYMOUS | SVC_SOCK_TEMPORARY)))) 904 (SVC_SOCK_ANONYMOUS | SVC_SOCK_TEMPORARY));
905 if (IS_ERR(newsvsk))
905 goto failed; 906 goto failed;
906 svc_xprt_set_remote(&newsvsk->sk_xprt, sin, slen); 907 svc_xprt_set_remote(&newsvsk->sk_xprt, sin, slen);
907 err = kernel_getsockname(newsock, sin, &slen); 908 err = kernel_getsockname(newsock, sin, &slen);
@@ -1383,29 +1384,29 @@ EXPORT_SYMBOL_GPL(svc_sock_update_bufs);
1383 */ 1384 */
1384static struct svc_sock *svc_setup_socket(struct svc_serv *serv, 1385static struct svc_sock *svc_setup_socket(struct svc_serv *serv,
1385 struct socket *sock, 1386 struct socket *sock,
1386 int *errp, int flags) 1387 int flags)
1387{ 1388{
1388 struct svc_sock *svsk; 1389 struct svc_sock *svsk;
1389 struct sock *inet; 1390 struct sock *inet;
1390 int pmap_register = !(flags & SVC_SOCK_ANONYMOUS); 1391 int pmap_register = !(flags & SVC_SOCK_ANONYMOUS);
1392 int err = 0;
1391 1393
1392 dprintk("svc: svc_setup_socket %p\n", sock); 1394 dprintk("svc: svc_setup_socket %p\n", sock);
1393 if (!(svsk = kzalloc(sizeof(*svsk), GFP_KERNEL))) { 1395 svsk = kzalloc(sizeof(*svsk), GFP_KERNEL);
1394 *errp = -ENOMEM; 1396 if (!svsk)
1395 return NULL; 1397 return ERR_PTR(-ENOMEM);
1396 }
1397 1398
1398 inet = sock->sk; 1399 inet = sock->sk;
1399 1400
1400 /* Register socket with portmapper */ 1401 /* Register socket with portmapper */
1401 if (*errp >= 0 && pmap_register) 1402 if (pmap_register)
1402 *errp = svc_register(serv, sock_net(sock->sk), inet->sk_family, 1403 err = svc_register(serv, sock_net(sock->sk), inet->sk_family,
1403 inet->sk_protocol, 1404 inet->sk_protocol,
1404 ntohs(inet_sk(inet)->inet_sport)); 1405 ntohs(inet_sk(inet)->inet_sport));
1405 1406
1406 if (*errp < 0) { 1407 if (err < 0) {
1407 kfree(svsk); 1408 kfree(svsk);
1408 return NULL; 1409 return ERR_PTR(err);
1409 } 1410 }
1410 1411
1411 inet->sk_user_data = svsk; 1412 inet->sk_user_data = svsk;
@@ -1463,10 +1464,12 @@ int svc_addsock(struct svc_serv *serv, const int fd, char *name_return,
1463 else { 1464 else {
1464 if (!try_module_get(THIS_MODULE)) 1465 if (!try_module_get(THIS_MODULE))
1465 err = -ENOENT; 1466 err = -ENOENT;
1466 else 1467 else {
1467 svsk = svc_setup_socket(serv, so, &err, 1468 svsk = svc_setup_socket(serv, so, SVC_SOCK_DEFAULTS);
1468 SVC_SOCK_DEFAULTS); 1469 if (IS_ERR(svsk))
1469 if (svsk) { 1470 err = PTR_ERR(svsk);
1471 }
1472 if (err == 0) {
1470 struct sockaddr_storage addr; 1473 struct sockaddr_storage addr;
1471 struct sockaddr *sin = (struct sockaddr *)&addr; 1474 struct sockaddr *sin = (struct sockaddr *)&addr;
1472 int salen; 1475 int salen;
@@ -1563,11 +1566,12 @@ static struct svc_xprt *svc_create_socket(struct svc_serv *serv,
1563 goto bummer; 1566 goto bummer;
1564 } 1567 }
1565 1568
1566 if ((svsk = svc_setup_socket(serv, sock, &error, flags)) != NULL) { 1569 svsk = svc_setup_socket(serv, sock, flags);
1570 if (!IS_ERR(svsk)) {
1567 svc_xprt_set_local(&svsk->sk_xprt, newsin, newlen); 1571 svc_xprt_set_local(&svsk->sk_xprt, newsin, newlen);
1568 return (struct svc_xprt *)svsk; 1572 return (struct svc_xprt *)svsk;
1569 } 1573 }
1570 1574 error = PTR_ERR(svsk);
1571bummer: 1575bummer:
1572 dprintk("svc: svc_create_socket error = %d\n", -error); 1576 dprintk("svc: svc_create_socket error = %d\n", -error);
1573 sock_release(sock); 1577 sock_release(sock);