X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/0a7de7458d150b5d4dffc935ba399be265ef0a1a..HEAD:/bsd/nfs/xdr_subs.h diff --git a/bsd/nfs/xdr_subs.h b/bsd/nfs/xdr_subs.h index 24295f487..1af6749cd 100644 --- a/bsd/nfs/xdr_subs.h +++ b/bsd/nfs/xdr_subs.h @@ -100,14 +100,17 @@ * * generalized functionality for managing the building/dissecting of XDR data */ -typedef enum xdrbuf_type { XDRBUF_BUFFER=1 } xdrbuf_type; +typedef enum xdrbuf_type { + XDRBUF_NONE = 0, + XDRBUF_BUFFER = 1, +} xdrbuf_type; struct xdrbuf { union { struct { char * xbb_base; /* base address of buffer */ - uint32_t xbb_size; /* size of buffer */ - uint32_t xbb_len; /* length of data in buffer */ + size_t xbb_size; /* size of buffer */ + size_t xbb_len; /* length of data in buffer */ } xb_buffer; } xb_u; char * xb_ptr; /* pointer to current position */ @@ -131,10 +134,10 @@ void xb_free(void *); int xb_grow(struct xdrbuf *); void xb_set_cur_buf_len(struct xdrbuf *); char *xb_buffer_base(struct xdrbuf *); -int xb_advance(struct xdrbuf *, uint32_t); -int xb_offset(struct xdrbuf *); -int xb_seek(struct xdrbuf *, uint32_t); -int xb_add_bytes(struct xdrbuf *, const char *, uint32_t, int); +int xb_advance(struct xdrbuf *, size_t); +size_t xb_offset(struct xdrbuf *); +int xb_seek(struct xdrbuf *, size_t); +int xb_add_bytes(struct xdrbuf *, const char *, size_t, int); int xb_get_bytes(struct xdrbuf *, char *, uint32_t, int); #ifdef _NFS_XDR_SUBS_FUNCS_ @@ -192,6 +195,8 @@ xb_cleanup(struct xdrbuf *xbp) xb_free(xbp->xb_u.xb_buffer.xbb_base); } break; + default: + break; } xbp->xb_flags &= ~XB_CLEANUP; } @@ -207,6 +212,8 @@ xb_set_cur_buf_len(struct xdrbuf *xbp) case XDRBUF_BUFFER: xbp->xb_u.xb_buffer.xbb_len = xbp->xb_ptr - xbp->xb_u.xb_buffer.xbb_base; break; + default: + break; } } @@ -214,9 +221,9 @@ xb_set_cur_buf_len(struct xdrbuf *xbp) * advance forward through existing data in xdrbuf */ int -xb_advance(struct xdrbuf *xbp, uint32_t len) +xb_advance(struct xdrbuf *xbp, size_t len) { - uint32_t tlen; + size_t tlen; while (len) { if (xbp->xb_left <= 0) { @@ -235,15 +242,17 @@ xb_advance(struct xdrbuf *xbp, uint32_t len) /* * Calculate the current offset in the XDR buffer. */ -int +size_t xb_offset(struct xdrbuf *xbp) { - uint32_t offset = 0; + size_t offset = 0; switch (xbp->xb_type) { case XDRBUF_BUFFER: offset = xbp->xb_ptr - xbp->xb_u.xb_buffer.xbb_base; break; + default: + break; } return offset; @@ -253,13 +262,15 @@ xb_offset(struct xdrbuf *xbp) * Seek to the given offset in the existing data in the XDR buffer. */ int -xb_seek(struct xdrbuf *xbp, uint32_t offset) +xb_seek(struct xdrbuf *xbp, size_t offset) { switch (xbp->xb_type) { case XDRBUF_BUFFER: xbp->xb_ptr = xbp->xb_u.xb_buffer.xbb_base + offset; xbp->xb_left = xbp->xb_u.xb_buffer.xbb_len - offset; break; + default: + break; } return 0; @@ -323,6 +334,8 @@ xb_grow(struct xdrbuf *xbp) xbp->xb_ptr = newbuf + oldsize; xbp->xb_left = xbp->xb_growsize; break; + default: + break; } return 0; @@ -334,9 +347,9 @@ xb_grow(struct xdrbuf *xbp) * Add "count" bytes of opaque data pointed to by "buf" to the given XDR buffer. */ int -xb_add_bytes(struct xdrbuf *xbp, const char *buf, uint32_t count, int nopad) +xb_add_bytes(struct xdrbuf *xbp, const char *buf, size_t count, int nopad) { - uint32_t len, tlen; + size_t len, tlen; int error; len = nopad ? count : xdr_rndup(count); @@ -382,7 +395,7 @@ xb_add_bytes(struct xdrbuf *xbp, const char *buf, uint32_t count, int nopad) int xb_get_bytes(struct xdrbuf *xbp, char *buf, uint32_t count, int nopad) { - uint32_t len, tlen; + size_t len, tlen; len = nopad ? count : xdr_rndup(count); @@ -486,6 +499,7 @@ xb_get_bytes(struct xdrbuf *xbp, char *buf, uint32_t count, int nopad) #define xb_get_32(E, XB, LVAL) \ do { \ uint32_t __tmp; \ + (LVAL) = (typeof((LVAL))) 0; \ if (E) break; \ (E) = xb_get_bytes((XB), (char*)&__tmp, XDRWORD, 0); \ if (E) break; \ @@ -496,6 +510,7 @@ xb_get_bytes(struct xdrbuf *xbp, char *buf, uint32_t count, int nopad) #define xb_get_64(E, XB, LVAL) \ do { \ uint64_t __tmp; \ + (LVAL) = 0; \ if (E) break; \ (E) = xb_get_bytes((XB), (char*)&__tmp, 2 * XDRWORD, 0); \ if (E) break; \