Commit bd00f84b authored by Trond Myklebust's avatar Trond Myklebust

SUNRPC: Simplify the end-of-buffer calculation in xdr_read_pages

Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent b760b313
...@@ -762,11 +762,10 @@ unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len) ...@@ -762,11 +762,10 @@ unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len)
{ {
struct xdr_buf *buf = xdr->buf; struct xdr_buf *buf = xdr->buf;
struct kvec *iov; struct kvec *iov;
ssize_t shift;
unsigned int nwords = XDR_QUADLEN(len); unsigned int nwords = XDR_QUADLEN(len);
unsigned int cur = xdr_stream_pos(xdr); unsigned int cur = xdr_stream_pos(xdr);
unsigned int end; unsigned int end;
int padding; unsigned int padding;
if (xdr->nwords == 0) if (xdr->nwords == 0)
return 0; return 0;
...@@ -782,15 +781,15 @@ unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len) ...@@ -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 */ /* Truncate page data and move it into the tail */
if (buf->page_len > len) if (buf->page_len > len)
xdr_shrink_pagelen(buf, buf->page_len - len); xdr_shrink_pagelen(buf, buf->page_len - len);
xdr->nwords = XDR_QUADLEN(buf->len - cur);
padding = (nwords << 2) - len; padding = (nwords << 2) - len;
xdr->iov = iov = buf->tail; xdr->iov = iov = buf->tail;
/* Compute remaining message length. */ /* Compute remaining message length. */
end = iov->iov_len; end = ((xdr->nwords - nwords) << 2) + padding;
shift = buf->buflen - buf->len; if (end > iov->iov_len)
if (end > shift + padding) end = iov->iov_len;
end -= shift;
else
end = padding;
/* /*
* Position current pointer at beginning of tail, and * Position current pointer at beginning of tail, and
* set remaining message length. * set remaining message length.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment