aboutsummaryrefslogtreecommitdiff
path: root/net/sunrpc/xdr.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2012-06-26 13:50:43 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-06-28 17:20:46 -0400
commitbd00f84bc57f42df32c728e86329a5c30f221657 (patch)
tree08eaa71f9354381f15135445b7ac7d6f431e855c /net/sunrpc/xdr.c
parentb760b3131d962dd35925fb65956afe621fa65ec4 (diff)
SUNRPC: Simplify the end-of-buffer calculation in xdr_read_pages
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/xdr.c')
-rw-r--r--net/sunrpc/xdr.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index faf6753c593..834d4da9cdb 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -762,11 +762,10 @@ unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len)
{
struct xdr_buf *buf = xdr->buf;
struct kvec *iov;
- ssize_t shift;
unsigned int nwords = XDR_QUADLEN(len);
unsigned int cur = xdr_stream_pos(xdr);
unsigned int end;
- int padding;
+ unsigned int padding;
if (xdr->nwords == 0)
return 0;
@@ -782,15 +781,15 @@ unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len)
/* Truncate page data and move it into the tail */
if (buf->page_len > len)
xdr_shrink_pagelen(buf, buf->page_len - len);
+ xdr->nwords = XDR_QUADLEN(buf->len - cur);
+
padding = (nwords << 2) - len;
xdr->iov = iov = buf->tail;
/* Compute remaining message length. */
- end = iov->iov_len;
- shift = buf->buflen - buf->len;
- if (end > shift + padding)
- end -= shift;
- else
- end = padding;
+ end = ((xdr->nwords - nwords) << 2) + padding;
+ if (end > iov->iov_len)
+ end = iov->iov_len;
+
/*
* Position current pointer at beginning of tail, and
* set remaining message length.