Commit f8d0e60f authored by Trond Myklebust's avatar Trond Myklebust

SUNRPC: Cleanup - constify a number of xdr_buf helpers

There are a number of xdr helpers for struct xdr_buf that do not change
the structure itself. Mark those as taking const pointers for
documentation purposes.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 5a5f1c2c
...@@ -128,8 +128,8 @@ __be32 *xdr_decode_netobj(__be32 *p, struct xdr_netobj *); ...@@ -128,8 +128,8 @@ __be32 *xdr_decode_netobj(__be32 *p, struct xdr_netobj *);
void xdr_inline_pages(struct xdr_buf *, unsigned int, void xdr_inline_pages(struct xdr_buf *, unsigned int,
struct page **, unsigned int, unsigned int); struct page **, unsigned int, unsigned int);
void xdr_terminate_string(struct xdr_buf *, const u32); void xdr_terminate_string(const struct xdr_buf *, const u32);
size_t xdr_buf_pagecount(struct xdr_buf *buf); size_t xdr_buf_pagecount(const struct xdr_buf *buf);
int xdr_alloc_bvec(struct xdr_buf *buf, gfp_t gfp); int xdr_alloc_bvec(struct xdr_buf *buf, gfp_t gfp);
void xdr_free_bvec(struct xdr_buf *buf); void xdr_free_bvec(struct xdr_buf *buf);
...@@ -182,14 +182,14 @@ xdr_adjust_iovec(struct kvec *iov, __be32 *p) ...@@ -182,14 +182,14 @@ xdr_adjust_iovec(struct kvec *iov, __be32 *p)
* XDR buffer helper functions * XDR buffer helper functions
*/ */
extern void xdr_shift_buf(struct xdr_buf *, size_t); extern void xdr_shift_buf(struct xdr_buf *, size_t);
extern void xdr_buf_from_iov(struct kvec *, struct xdr_buf *); extern void xdr_buf_from_iov(const struct kvec *, struct xdr_buf *);
extern int xdr_buf_subsegment(struct xdr_buf *, struct xdr_buf *, unsigned int, unsigned int); extern int xdr_buf_subsegment(const struct xdr_buf *, struct xdr_buf *, unsigned int, unsigned int);
extern void xdr_buf_trim(struct xdr_buf *, unsigned int); extern void xdr_buf_trim(struct xdr_buf *, unsigned int);
extern int read_bytes_from_xdr_buf(struct xdr_buf *, unsigned int, void *, unsigned int); extern int read_bytes_from_xdr_buf(const struct xdr_buf *, unsigned int, void *, unsigned int);
extern int write_bytes_to_xdr_buf(struct xdr_buf *, unsigned int, void *, unsigned int); extern int write_bytes_to_xdr_buf(const struct xdr_buf *, unsigned int, void *, unsigned int);
extern int xdr_encode_word(struct xdr_buf *, unsigned int, u32); extern int xdr_encode_word(const struct xdr_buf *, unsigned int, u32);
extern int xdr_decode_word(struct xdr_buf *, unsigned int, u32 *); extern int xdr_decode_word(const struct xdr_buf *, unsigned int, u32 *);
struct xdr_array2_desc; struct xdr_array2_desc;
typedef int (*xdr_xcode_elem_t)(struct xdr_array2_desc *desc, void *elem); typedef int (*xdr_xcode_elem_t)(struct xdr_array2_desc *desc, void *elem);
...@@ -200,9 +200,9 @@ struct xdr_array2_desc { ...@@ -200,9 +200,9 @@ struct xdr_array2_desc {
xdr_xcode_elem_t xcode; xdr_xcode_elem_t xcode;
}; };
extern int xdr_decode_array2(struct xdr_buf *buf, unsigned int base, extern int xdr_decode_array2(const struct xdr_buf *buf, unsigned int base,
struct xdr_array2_desc *desc); struct xdr_array2_desc *desc);
extern int xdr_encode_array2(struct xdr_buf *buf, unsigned int base, extern int xdr_encode_array2(const struct xdr_buf *buf, unsigned int base,
struct xdr_array2_desc *desc); struct xdr_array2_desc *desc);
extern void _copy_from_pages(char *p, struct page **pages, size_t pgbase, extern void _copy_from_pages(char *p, struct page **pages, size_t pgbase,
size_t len); size_t len);
...@@ -251,7 +251,7 @@ extern void xdr_set_scratch_buffer(struct xdr_stream *xdr, void *buf, size_t buf ...@@ -251,7 +251,7 @@ extern void xdr_set_scratch_buffer(struct xdr_stream *xdr, void *buf, size_t buf
extern __be32 *xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes); extern __be32 *xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes);
extern unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len); extern unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len);
extern void xdr_enter_page(struct xdr_stream *xdr, unsigned int len); extern void xdr_enter_page(struct xdr_stream *xdr, unsigned int len);
extern int xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len, int (*actor)(struct scatterlist *, void *), void *data); extern int xdr_process_buf(const struct xdr_buf *buf, unsigned int offset, unsigned int len, int (*actor)(struct scatterlist *, void *), void *data);
extern unsigned int xdr_align_data(struct xdr_stream *, unsigned int offset, unsigned int length); extern unsigned int xdr_align_data(struct xdr_stream *, unsigned int offset, unsigned int length);
extern unsigned int xdr_expand_hole(struct xdr_stream *, unsigned int offset, unsigned int length); extern unsigned int xdr_expand_hole(struct xdr_stream *, unsigned int offset, unsigned int length);
......
...@@ -123,8 +123,7 @@ EXPORT_SYMBOL_GPL(xdr_decode_string_inplace); ...@@ -123,8 +123,7 @@ EXPORT_SYMBOL_GPL(xdr_decode_string_inplace);
* @len: length of string, in bytes * @len: length of string, in bytes
* *
*/ */
void void xdr_terminate_string(const struct xdr_buf *buf, const u32 len)
xdr_terminate_string(struct xdr_buf *buf, const u32 len)
{ {
char *kaddr; char *kaddr;
...@@ -134,8 +133,7 @@ xdr_terminate_string(struct xdr_buf *buf, const u32 len) ...@@ -134,8 +133,7 @@ xdr_terminate_string(struct xdr_buf *buf, const u32 len)
} }
EXPORT_SYMBOL_GPL(xdr_terminate_string); EXPORT_SYMBOL_GPL(xdr_terminate_string);
size_t size_t xdr_buf_pagecount(const struct xdr_buf *buf)
xdr_buf_pagecount(struct xdr_buf *buf)
{ {
if (!buf->page_len) if (!buf->page_len)
return 0; return 0;
...@@ -1545,8 +1543,7 @@ EXPORT_SYMBOL_GPL(xdr_enter_page); ...@@ -1545,8 +1543,7 @@ EXPORT_SYMBOL_GPL(xdr_enter_page);
static const struct kvec empty_iov = {.iov_base = NULL, .iov_len = 0}; static const struct kvec empty_iov = {.iov_base = NULL, .iov_len = 0};
void void xdr_buf_from_iov(const struct kvec *iov, struct xdr_buf *buf)
xdr_buf_from_iov(struct kvec *iov, struct xdr_buf *buf)
{ {
buf->head[0] = *iov; buf->head[0] = *iov;
buf->tail[0] = empty_iov; buf->tail[0] = empty_iov;
...@@ -1569,8 +1566,7 @@ EXPORT_SYMBOL_GPL(xdr_buf_from_iov); ...@@ -1569,8 +1566,7 @@ EXPORT_SYMBOL_GPL(xdr_buf_from_iov);
* *
* Returns -1 if base of length are out of bounds. * Returns -1 if base of length are out of bounds.
*/ */
int int xdr_buf_subsegment(const struct xdr_buf *buf, struct xdr_buf *subbuf,
xdr_buf_subsegment(struct xdr_buf *buf, struct xdr_buf *subbuf,
unsigned int base, unsigned int len) unsigned int base, unsigned int len)
{ {
subbuf->buflen = subbuf->len = len; subbuf->buflen = subbuf->len = len;
...@@ -1659,7 +1655,8 @@ void xdr_buf_trim(struct xdr_buf *buf, unsigned int len) ...@@ -1659,7 +1655,8 @@ void xdr_buf_trim(struct xdr_buf *buf, unsigned int len)
} }
EXPORT_SYMBOL_GPL(xdr_buf_trim); EXPORT_SYMBOL_GPL(xdr_buf_trim);
static void __read_bytes_from_xdr_buf(struct xdr_buf *subbuf, void *obj, unsigned int len) static void __read_bytes_from_xdr_buf(const struct xdr_buf *subbuf,
void *obj, unsigned int len)
{ {
unsigned int this_len; unsigned int this_len;
...@@ -1676,7 +1673,8 @@ static void __read_bytes_from_xdr_buf(struct xdr_buf *subbuf, void *obj, unsigne ...@@ -1676,7 +1673,8 @@ static void __read_bytes_from_xdr_buf(struct xdr_buf *subbuf, void *obj, unsigne
} }
/* obj is assumed to point to allocated memory of size at least len: */ /* obj is assumed to point to allocated memory of size at least len: */
int read_bytes_from_xdr_buf(struct xdr_buf *buf, unsigned int base, void *obj, unsigned int len) int read_bytes_from_xdr_buf(const struct xdr_buf *buf, unsigned int base,
void *obj, unsigned int len)
{ {
struct xdr_buf subbuf; struct xdr_buf subbuf;
int status; int status;
...@@ -1689,7 +1687,8 @@ int read_bytes_from_xdr_buf(struct xdr_buf *buf, unsigned int base, void *obj, u ...@@ -1689,7 +1687,8 @@ int read_bytes_from_xdr_buf(struct xdr_buf *buf, unsigned int base, void *obj, u
} }
EXPORT_SYMBOL_GPL(read_bytes_from_xdr_buf); EXPORT_SYMBOL_GPL(read_bytes_from_xdr_buf);
static void __write_bytes_to_xdr_buf(struct xdr_buf *subbuf, void *obj, unsigned int len) static void __write_bytes_to_xdr_buf(const struct xdr_buf *subbuf,
void *obj, unsigned int len)
{ {
unsigned int this_len; unsigned int this_len;
...@@ -1706,7 +1705,8 @@ static void __write_bytes_to_xdr_buf(struct xdr_buf *subbuf, void *obj, unsigned ...@@ -1706,7 +1705,8 @@ static void __write_bytes_to_xdr_buf(struct xdr_buf *subbuf, void *obj, unsigned
} }
/* obj is assumed to point to allocated memory of size at least len: */ /* obj is assumed to point to allocated memory of size at least len: */
int write_bytes_to_xdr_buf(struct xdr_buf *buf, unsigned int base, void *obj, unsigned int len) int write_bytes_to_xdr_buf(const struct xdr_buf *buf, unsigned int base,
void *obj, unsigned int len)
{ {
struct xdr_buf subbuf; struct xdr_buf subbuf;
int status; int status;
...@@ -1719,8 +1719,7 @@ int write_bytes_to_xdr_buf(struct xdr_buf *buf, unsigned int base, void *obj, un ...@@ -1719,8 +1719,7 @@ int write_bytes_to_xdr_buf(struct xdr_buf *buf, unsigned int base, void *obj, un
} }
EXPORT_SYMBOL_GPL(write_bytes_to_xdr_buf); EXPORT_SYMBOL_GPL(write_bytes_to_xdr_buf);
int int xdr_decode_word(const struct xdr_buf *buf, unsigned int base, u32 *obj)
xdr_decode_word(struct xdr_buf *buf, unsigned int base, u32 *obj)
{ {
__be32 raw; __be32 raw;
int status; int status;
...@@ -1733,8 +1732,7 @@ xdr_decode_word(struct xdr_buf *buf, unsigned int base, u32 *obj) ...@@ -1733,8 +1732,7 @@ xdr_decode_word(struct xdr_buf *buf, unsigned int base, u32 *obj)
} }
EXPORT_SYMBOL_GPL(xdr_decode_word); EXPORT_SYMBOL_GPL(xdr_decode_word);
int int xdr_encode_word(const struct xdr_buf *buf, unsigned int base, u32 obj)
xdr_encode_word(struct xdr_buf *buf, unsigned int base, u32 obj)
{ {
__be32 raw = cpu_to_be32(obj); __be32 raw = cpu_to_be32(obj);
...@@ -1743,8 +1741,7 @@ xdr_encode_word(struct xdr_buf *buf, unsigned int base, u32 obj) ...@@ -1743,8 +1741,7 @@ xdr_encode_word(struct xdr_buf *buf, unsigned int base, u32 obj)
EXPORT_SYMBOL_GPL(xdr_encode_word); EXPORT_SYMBOL_GPL(xdr_encode_word);
/* Returns 0 on success, or else a negative error code. */ /* Returns 0 on success, or else a negative error code. */
static int static int xdr_xcode_array2(const struct xdr_buf *buf, unsigned int base,
xdr_xcode_array2(struct xdr_buf *buf, unsigned int base,
struct xdr_array2_desc *desc, int encode) struct xdr_array2_desc *desc, int encode)
{ {
char *elem = NULL, *c; char *elem = NULL, *c;
...@@ -1937,8 +1934,7 @@ xdr_xcode_array2(struct xdr_buf *buf, unsigned int base, ...@@ -1937,8 +1934,7 @@ xdr_xcode_array2(struct xdr_buf *buf, unsigned int base,
return err; return err;
} }
int int xdr_decode_array2(const struct xdr_buf *buf, unsigned int base,
xdr_decode_array2(struct xdr_buf *buf, unsigned int base,
struct xdr_array2_desc *desc) struct xdr_array2_desc *desc)
{ {
if (base >= buf->len) if (base >= buf->len)
...@@ -1948,8 +1944,7 @@ xdr_decode_array2(struct xdr_buf *buf, unsigned int base, ...@@ -1948,8 +1944,7 @@ xdr_decode_array2(struct xdr_buf *buf, unsigned int base,
} }
EXPORT_SYMBOL_GPL(xdr_decode_array2); EXPORT_SYMBOL_GPL(xdr_decode_array2);
int int xdr_encode_array2(const struct xdr_buf *buf, unsigned int base,
xdr_encode_array2(struct xdr_buf *buf, unsigned int base,
struct xdr_array2_desc *desc) struct xdr_array2_desc *desc)
{ {
if ((unsigned long) base + 4 + desc->array_len * desc->elem_size > if ((unsigned long) base + 4 + desc->array_len * desc->elem_size >
...@@ -1960,8 +1955,8 @@ xdr_encode_array2(struct xdr_buf *buf, unsigned int base, ...@@ -1960,8 +1955,8 @@ xdr_encode_array2(struct xdr_buf *buf, unsigned int base,
} }
EXPORT_SYMBOL_GPL(xdr_encode_array2); EXPORT_SYMBOL_GPL(xdr_encode_array2);
int int xdr_process_buf(const struct xdr_buf *buf, unsigned int offset,
xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len, unsigned int len,
int (*actor)(struct scatterlist *, void *), void *data) int (*actor)(struct scatterlist *, void *), void *data)
{ {
int i, ret = 0; int i, ret = 0;
......
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