Skip to contentSkip to conversation

SUNRPC: Use more consistent variable typing in xs_send_pagedata

PATCH In review Chuck Lever 1 participant 1 message May 25, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 7/10 SUNRPC: Use more consistent variable typing in xs_send_pagedata

The 3rd argument of ->sendpage is an "int" and the 4th is a "size_t". Make sure that comparison between the "int" return value and a "size_t" variable is explicitly cast.

---

 net/sunrpc/xprtsock.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
net/sunrpc/xprtsock.c +8 -4
index cc33c58..dd2a9db 100644
@@ -319,7 +319,8 @@ static int xs_send_kvec(struct socket *sock, struct sockaddr *addr, int addrlen,
 	return kernel_sendmsg(sock, &msg, NULL, 0, 0);
 }
 
-static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more)
+static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr,
+			    unsigned int base, int more)
 {
 	struct page **ppage;
 	unsigned int remainder;
@@ -330,14 +331,17 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
 	ppage = xdr->pages + (base >> PAGE_SHIFT);
 	base &= ~PAGE_MASK;
 	for(;;) {
-		unsigned int len = min_t(unsigned int, PAGE_SIZE - base, remainder);
+		size_t len = min_t(size_t, PAGE_SIZE - base, remainder);
 		int flags = XS_SENDMSG_FLAGS;
 
 		remainder -= len;
 		if (remainder != 0 || more)
 			flags |= MSG_MORE;
-		err = sock->ops->sendpage(sock, *ppage, base, len, flags);
-		if (remainder == 0 || err != len)
+		err = sock->ops->sendpage(sock, *ppage, (int)base, len, flags);
+		if (err < 0 || (size_t)err != len)
+			break;
+
+		if (remainder == 0)
 			break;
 		sent += err;
 		ppage++;

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs