diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-06-26 13:50:43 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-06-28 17:20:46 -0400 |
commit | bd00f84bc57f42df32c728e86329a5c30f221657 (patch) | |
tree | 08eaa71f9354381f15135445b7ac7d6f431e855c /net/sunrpc/xdr.c | |
parent | b760b3131d962dd35925fb65956afe621fa65ec4 (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.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index faf6753c593d..834d4da9cdb0 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) | |||
762 | { | 762 | { |
763 | struct xdr_buf *buf = xdr->buf; | 763 | struct xdr_buf *buf = xdr->buf; |
764 | struct kvec *iov; | 764 | struct kvec *iov; |
765 | ssize_t shift; | ||
766 | unsigned int nwords = XDR_QUADLEN(len); | 765 | unsigned int nwords = XDR_QUADLEN(len); |
767 | unsigned int cur = xdr_stream_pos(xdr); | 766 | unsigned int cur = xdr_stream_pos(xdr); |
768 | unsigned int end; | 767 | unsigned int end; |
769 | int padding; | 768 | unsigned int padding; |
770 | 769 | ||
771 | if (xdr->nwords == 0) | 770 | if (xdr->nwords == 0) |
772 | return 0; | 771 | return 0; |
@@ -782,15 +781,15 @@ unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len) | |||
782 | /* Truncate page data and move it into the tail */ | 781 | /* Truncate page data and move it into the tail */ |
783 | if (buf->page_len > len) | 782 | if (buf->page_len > len) |
784 | xdr_shrink_pagelen(buf, buf->page_len - len); | 783 | xdr_shrink_pagelen(buf, buf->page_len - len); |
784 | xdr->nwords = XDR_QUADLEN(buf->len - cur); | ||
785 | |||
785 | padding = (nwords << 2) - len; | 786 | padding = (nwords << 2) - len; |
786 | xdr->iov = iov = buf->tail; | 787 | xdr->iov = iov = buf->tail; |
787 | /* Compute remaining message length. */ | 788 | /* Compute remaining message length. */ |
788 | end = iov->iov_len; | 789 | end = ((xdr->nwords - nwords) << 2) + padding; |
789 | shift = buf->buflen - buf->len; | 790 | if (end > iov->iov_len) |
790 | if (end > shift + padding) | 791 | end = iov->iov_len; |
791 | end -= shift; | 792 | |
792 | else | ||
793 | end = padding; | ||
794 | /* | 793 | /* |
795 | * Position current pointer at beginning of tail, and | 794 | * Position current pointer at beginning of tail, and |
796 | * set remaining message length. | 795 | * set remaining message length. |