2007-03-27 14:52:31

by Olaf Kirch

[permalink] [raw]
Subject: [PATCH] sunrpc: fix typo in svc_udp_recvfrom

I'm not sure whether this has been brought up already - I came
across this today when poking around the code...

Olaf

--[ cut here ]--
Fix a typo in svc_udp_recvfrom

This patch corrects a small and hamless typo in svc_udp_recvfrom.

Signed-off-by: [email protected]
---
net/sunrpc/svcsock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/net/sunrpc/svcsock.c
===================================================================
--- linux-2.6.orig/net/sunrpc/svcsock.c
+++ linux-2.6/net/sunrpc/svcsock.c
@@ -779,7 +779,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
}

clear_bit(SK_DATA, &svsk->sk_flags);
- while ((err == kernel_recvmsg(svsk->sk_sock, &msg, NULL,
+ while ((err = kernel_recvmsg(svsk->sk_sock, &msg, NULL,
0, 0, MSG_PEEK | MSG_DONTWAIT)) < 0 ||
(skb = skb_recv_datagram(svsk->sk_sk, 0, 1, &err)) == NULL) {
if (err == -EAGAIN) {

--
Olaf Kirch | --- o --- Nous sommes du soleil we love when we play
[email protected] | / | \ sol.dhoop.naytheet.ah kin.ir.samse.qurax

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs


2007-03-27 15:10:17

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH] sunrpc: fix typo in svc_udp_recvfrom

On Tue, 2007-03-27 at 16:51 +0200, Olaf Kirch wrote:
> I'm not sure whether this has been brought up already - I came
> across this today when poking around the code...
>
> Olaf
>
> --[ cut here ]--
> Fix a typo in svc_udp_recvfrom
>
> This patch corrects a small and hamless typo in svc_udp_recvfrom.
>
> Signed-off-by: [email protected]
> ---
> net/sunrpc/svcsock.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Index: linux-2.6/net/sunrpc/svcsock.c
> ===================================================================
> --- linux-2.6.orig/net/sunrpc/svcsock.c
> +++ linux-2.6/net/sunrpc/svcsock.c
> @@ -779,7 +779,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
> }
>
> clear_bit(SK_DATA, &svsk->sk_flags);
> - while ((err == kernel_recvmsg(svsk->sk_sock, &msg, NULL,
> + while ((err = kernel_recvmsg(svsk->sk_sock, &msg, NULL,
> 0, 0, MSG_PEEK | MSG_DONTWAIT)) < 0 ||
> (skb = skb_recv_datagram(svsk->sk_sk, 0, 1, &err)) == NULL) {
> if (err == -EAGAIN) {

Could you please rather move those assignments out of the while()? Good
coding style dictates that the above should be avoided. One of the
benefits is precisely to avoid the above ambiguities.

Something like

for (;;) {
err = kernel_recvmsg(svsk->sk_sock, &msg, NULL, 0, 0, MSG_PEEK|MSG_DONTWAIT);
if (err == 0) {
skb = skb_recv_datagram(svsk->sk_sk, 0, 1, &err);
if (skb != NULL)
break;
}
if (err == -EAGAIN) {
svc_sock_received(svsk);
return err;
}
/* possibly an icmp error */
dprintk("svc: recvfrom returned error %d\n", -err);
}

Cheers,
Trond


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2007-03-27 15:41:10

by Olaf Kirch

[permalink] [raw]
Subject: [PATCH - try #2] sunrpc: fix typo in svc_udp_recvfrom

On Tuesday 27 March 2007 17:10, Trond Myklebust wrote:
> Could you please rather move those assignments out of the while()? Good
> coding style dictates that the above should be avoided. One of the
> benefits is precisely to avoid the above ambiguities.

Okay, here we go:
----------------------
Fix a typo in svc_udp_recvfrom

This patch corrects a small and harmless typo in svc_udp_recvfrom.

Signed-off-by: [email protected]
---
net/sunrpc/svcsock.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

Index: linux-2.6/net/sunrpc/svcsock.c
===================================================================
--- linux-2.6.orig/net/sunrpc/svcsock.c
+++ linux-2.6/net/sunrpc/svcsock.c
@@ -779,9 +779,14 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
}

clear_bit(SK_DATA, &svsk->sk_flags);
- while ((err == kernel_recvmsg(svsk->sk_sock, &msg, NULL,
- 0, 0, MSG_PEEK | MSG_DONTWAIT)) < 0 ||
- (skb = skb_recv_datagram(svsk->sk_sk, 0, 1, &err)) == NULL) {
+ while (1) {
+ err = kernel_recvmsg(svsk->sk_sock, &msg, NULL,
+ 0, 0, MSG_PEEK | MSG_DONTWAIT);
+ if (err >= 0) {
+ skb = skb_recv_datagram(svsk->sk_sk, 0, 1, &err);
+ if (skb)
+ break;
+ }
if (err == -EAGAIN) {
svc_sock_received(svsk);
return err;


--
Olaf Kirch | --- o --- Nous sommes du soleil we love when we play
[email protected] | / | \ sol.dhoop.naytheet.ah kin.ir.samse.qurax

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2007-03-27 16:08:05

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH - try #2] sunrpc: fix typo in svc_udp_recvfrom

On Tue, 2007-03-27 at 17:39 +0200, Olaf Kirch wrote:
> On Tuesday 27 March 2007 17:10, Trond Myklebust wrote:
> > Could you please rather move those assignments out of the while()? Good
> > coding style dictates that the above should be avoided. One of the
> > benefits is precisely to avoid the above ambiguities.
>
> Okay, here we go:
> ----------------------
> Fix a typo in svc_udp_recvfrom
>
> This patch corrects a small and harmless typo in svc_udp_recvfrom.
>
> Signed-off-by: [email protected]
> ---
> net/sunrpc/svcsock.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> Index: linux-2.6/net/sunrpc/svcsock.c
> ===================================================================
> --- linux-2.6.orig/net/sunrpc/svcsock.c
> +++ linux-2.6/net/sunrpc/svcsock.c
> @@ -779,9 +779,14 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
> }
>
> clear_bit(SK_DATA, &svsk->sk_flags);
> - while ((err == kernel_recvmsg(svsk->sk_sock, &msg, NULL,
> - 0, 0, MSG_PEEK | MSG_DONTWAIT)) < 0 ||
> - (skb = skb_recv_datagram(svsk->sk_sk, 0, 1, &err)) == NULL) {
> + while (1) {
> + err = kernel_recvmsg(svsk->sk_sock, &msg, NULL,
> + 0, 0, MSG_PEEK | MSG_DONTWAIT);
> + if (err >= 0) {
> + skb = skb_recv_datagram(svsk->sk_sk, 0, 1, &err);
> + if (skb)
> + break;
> + }
> if (err == -EAGAIN) {
> svc_sock_received(svsk);
> return err;
>

Thanks! That looks good to me.

Trond


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs