]> git.karo-electronics.de Git - linux-beck.git/commitdiff
SUNRPC: Remove open coded stream position calculation in xdr_read_pages
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 26 Jun 2012 16:19:55 +0000 (12:19 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Thu, 28 Jun 2012 21:20:45 +0000 (17:20 -0400)
Use xdr_stream_pos() instead.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
net/sunrpc/xdr.c

index 95980a5cd0a8190e4318dc1bd6adb9a323838c32..faf6753c593d0b224344a059114c2a2d2d01304b 100644 (file)
@@ -764,6 +764,7 @@ unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len)
        struct kvec *iov;
        ssize_t shift;
        unsigned int nwords = XDR_QUADLEN(len);
+       unsigned int cur = xdr_stream_pos(xdr);
        unsigned int end;
        int padding;
 
@@ -775,9 +776,8 @@ unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len)
        }
        /* Realign pages to current pointer position */
        iov  = buf->head;
-       shift = iov->iov_len + (char *)iov->iov_base - (char *)xdr->p;
-       if (shift > 0)
-               xdr_shrink_bufhead(buf, shift);
+       if (iov->iov_len > cur)
+               xdr_shrink_bufhead(buf, iov->iov_len - cur);
 
        /* Truncate page data and move it into the tail */
        if (buf->page_len > len)