aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/xdr.c
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2006-09-27 01:29:38 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-09-28 21:01:21 -0400
commitd8ed029d6000ba2e2908d9286409e4833c091b4c (patch)
tree732feaa2e3751df5c81032a30ff4761427492ac4 /net/sunrpc/xdr.c
parent7699431301b189fca7ccbb64fe54e5a5170f8497 (diff)
[SUNRPC]: trivial endianness annotations
pure s/u32/__be32/ [AV: large part based on Alexey's patches] Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sunrpc/xdr.c')
-rw-r--r--net/sunrpc/xdr.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 6ac45103a272..9022eb8b37ed 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -18,8 +18,8 @@
18/* 18/*
19 * XDR functions for basic NFS types 19 * XDR functions for basic NFS types
20 */ 20 */
21u32 * 21__be32 *
22xdr_encode_netobj(u32 *p, const struct xdr_netobj *obj) 22xdr_encode_netobj(__be32 *p, const struct xdr_netobj *obj)
23{ 23{
24 unsigned int quadlen = XDR_QUADLEN(obj->len); 24 unsigned int quadlen = XDR_QUADLEN(obj->len);
25 25
@@ -29,8 +29,8 @@ xdr_encode_netobj(u32 *p, const struct xdr_netobj *obj)
29 return p + XDR_QUADLEN(obj->len); 29 return p + XDR_QUADLEN(obj->len);
30} 30}
31 31
32u32 * 32__be32 *
33xdr_decode_netobj(u32 *p, struct xdr_netobj *obj) 33xdr_decode_netobj(__be32 *p, struct xdr_netobj *obj)
34{ 34{
35 unsigned int len; 35 unsigned int len;
36 36
@@ -55,7 +55,7 @@ xdr_decode_netobj(u32 *p, struct xdr_netobj *obj)
55 * Returns the updated current XDR buffer position 55 * Returns the updated current XDR buffer position
56 * 56 *
57 */ 57 */
58u32 *xdr_encode_opaque_fixed(u32 *p, const void *ptr, unsigned int nbytes) 58__be32 *xdr_encode_opaque_fixed(__be32 *p, const void *ptr, unsigned int nbytes)
59{ 59{
60 if (likely(nbytes != 0)) { 60 if (likely(nbytes != 0)) {
61 unsigned int quadlen = XDR_QUADLEN(nbytes); 61 unsigned int quadlen = XDR_QUADLEN(nbytes);
@@ -79,21 +79,21 @@ EXPORT_SYMBOL(xdr_encode_opaque_fixed);
79 * 79 *
80 * Returns the updated current XDR buffer position 80 * Returns the updated current XDR buffer position
81 */ 81 */
82u32 *xdr_encode_opaque(u32 *p, const void *ptr, unsigned int nbytes) 82__be32 *xdr_encode_opaque(__be32 *p, const void *ptr, unsigned int nbytes)
83{ 83{
84 *p++ = htonl(nbytes); 84 *p++ = htonl(nbytes);
85 return xdr_encode_opaque_fixed(p, ptr, nbytes); 85 return xdr_encode_opaque_fixed(p, ptr, nbytes);
86} 86}
87EXPORT_SYMBOL(xdr_encode_opaque); 87EXPORT_SYMBOL(xdr_encode_opaque);
88 88
89u32 * 89__be32 *
90xdr_encode_string(u32 *p, const char *string) 90xdr_encode_string(__be32 *p, const char *string)
91{ 91{
92 return xdr_encode_array(p, string, strlen(string)); 92 return xdr_encode_array(p, string, strlen(string));
93} 93}
94 94
95u32 * 95__be32 *
96xdr_decode_string_inplace(u32 *p, char **sp, int *lenp, int maxlen) 96xdr_decode_string_inplace(__be32 *p, char **sp, int *lenp, int maxlen)
97{ 97{
98 unsigned int len; 98 unsigned int len;
99 99
@@ -432,7 +432,7 @@ xdr_shift_buf(struct xdr_buf *buf, size_t len)
432 * of the buffer length, and takes care of adjusting the kvec 432 * of the buffer length, and takes care of adjusting the kvec
433 * length for us. 433 * length for us.
434 */ 434 */
435void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, uint32_t *p) 435void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p)
436{ 436{
437 struct kvec *iov = buf->head; 437 struct kvec *iov = buf->head;
438 int scratch_len = buf->buflen - buf->page_len - buf->tail[0].iov_len; 438 int scratch_len = buf->buflen - buf->page_len - buf->tail[0].iov_len;
@@ -440,8 +440,8 @@ void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, uint32_t *p)
440 BUG_ON(scratch_len < 0); 440 BUG_ON(scratch_len < 0);
441 xdr->buf = buf; 441 xdr->buf = buf;
442 xdr->iov = iov; 442 xdr->iov = iov;
443 xdr->p = (uint32_t *)((char *)iov->iov_base + iov->iov_len); 443 xdr->p = (__be32 *)((char *)iov->iov_base + iov->iov_len);
444 xdr->end = (uint32_t *)((char *)iov->iov_base + scratch_len); 444 xdr->end = (__be32 *)((char *)iov->iov_base + scratch_len);
445 BUG_ON(iov->iov_len > scratch_len); 445 BUG_ON(iov->iov_len > scratch_len);
446 446
447 if (p != xdr->p && p != NULL) { 447 if (p != xdr->p && p != NULL) {
@@ -465,10 +465,10 @@ EXPORT_SYMBOL(xdr_init_encode);
465 * bytes of data. If so, update the total xdr_buf length, and 465 * bytes of data. If so, update the total xdr_buf length, and
466 * adjust the length of the current kvec. 466 * adjust the length of the current kvec.
467 */ 467 */
468uint32_t * xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes) 468__be32 * xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes)
469{ 469{
470 uint32_t *p = xdr->p; 470 __be32 *p = xdr->p;
471 uint32_t *q; 471 __be32 *q;
472 472
473 /* align nbytes on the next 32-bit boundary */ 473 /* align nbytes on the next 32-bit boundary */
474 nbytes += 3; 474 nbytes += 3;
@@ -524,7 +524,7 @@ EXPORT_SYMBOL(xdr_write_pages);
524 * @buf: pointer to XDR buffer from which to decode data 524 * @buf: pointer to XDR buffer from which to decode data
525 * @p: current pointer inside XDR buffer 525 * @p: current pointer inside XDR buffer
526 */ 526 */
527void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, uint32_t *p) 527void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p)
528{ 528{
529 struct kvec *iov = buf->head; 529 struct kvec *iov = buf->head;
530 unsigned int len = iov->iov_len; 530 unsigned int len = iov->iov_len;
@@ -534,7 +534,7 @@ void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, uint32_t *p)
534 xdr->buf = buf; 534 xdr->buf = buf;
535 xdr->iov = iov; 535 xdr->iov = iov;
536 xdr->p = p; 536 xdr->p = p;
537 xdr->end = (uint32_t *)((char *)iov->iov_base + len); 537 xdr->end = (__be32 *)((char *)iov->iov_base + len);
538} 538}
539EXPORT_SYMBOL(xdr_init_decode); 539EXPORT_SYMBOL(xdr_init_decode);
540 540
@@ -548,10 +548,10 @@ EXPORT_SYMBOL(xdr_init_decode);
548 * If so return the current pointer, then update the current 548 * If so return the current pointer, then update the current
549 * pointer position. 549 * pointer position.
550 */ 550 */
551uint32_t * xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes) 551__be32 * xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes)
552{ 552{
553 uint32_t *p = xdr->p; 553 __be32 *p = xdr->p;
554 uint32_t *q = p + XDR_QUADLEN(nbytes); 554 __be32 *q = p + XDR_QUADLEN(nbytes);
555 555
556 if (unlikely(q > xdr->end || q < p)) 556 if (unlikely(q > xdr->end || q < p))
557 return NULL; 557 return NULL;
@@ -599,8 +599,8 @@ void xdr_read_pages(struct xdr_stream *xdr, unsigned int len)
599 * Position current pointer at beginning of tail, and 599 * Position current pointer at beginning of tail, and
600 * set remaining message length. 600 * set remaining message length.
601 */ 601 */
602 xdr->p = (uint32_t *)((char *)iov->iov_base + padding); 602 xdr->p = (__be32 *)((char *)iov->iov_base + padding);
603 xdr->end = (uint32_t *)((char *)iov->iov_base + end); 603 xdr->end = (__be32 *)((char *)iov->iov_base + end);
604} 604}
605EXPORT_SYMBOL(xdr_read_pages); 605EXPORT_SYMBOL(xdr_read_pages);
606 606
@@ -624,8 +624,8 @@ void xdr_enter_page(struct xdr_stream *xdr, unsigned int len)
624 */ 624 */
625 if (len > PAGE_CACHE_SIZE - xdr->buf->page_base) 625 if (len > PAGE_CACHE_SIZE - xdr->buf->page_base)
626 len = PAGE_CACHE_SIZE - xdr->buf->page_base; 626 len = PAGE_CACHE_SIZE - xdr->buf->page_base;
627 xdr->p = (uint32_t *)(kaddr + xdr->buf->page_base); 627 xdr->p = (__be32 *)(kaddr + xdr->buf->page_base);
628 xdr->end = (uint32_t *)((char *)xdr->p + len); 628 xdr->end = (__be32 *)((char *)xdr->p + len);
629} 629}
630EXPORT_SYMBOL(xdr_enter_page); 630EXPORT_SYMBOL(xdr_enter_page);
631 631
@@ -743,7 +743,7 @@ out:
743int 743int
744xdr_decode_word(struct xdr_buf *buf, int base, u32 *obj) 744xdr_decode_word(struct xdr_buf *buf, int base, u32 *obj)
745{ 745{
746 u32 raw; 746 __be32 raw;
747 int status; 747 int status;
748 748
749 status = read_bytes_from_xdr_buf(buf, base, &raw, sizeof(*obj)); 749 status = read_bytes_from_xdr_buf(buf, base, &raw, sizeof(*obj));
@@ -756,7 +756,7 @@ xdr_decode_word(struct xdr_buf *buf, int base, u32 *obj)
756int 756int
757xdr_encode_word(struct xdr_buf *buf, int base, u32 obj) 757xdr_encode_word(struct xdr_buf *buf, int base, u32 obj)
758{ 758{
759 u32 raw = htonl(obj); 759 __be32 raw = htonl(obj);
760 760
761 return write_bytes_to_xdr_buf(buf, base, &raw, sizeof(obj)); 761 return write_bytes_to_xdr_buf(buf, base, &raw, sizeof(obj));
762} 762}