From: Trond Myklebust RPC,NFSv3: remove the redundant "memset()" in call_encode(). Fix up the only places where this causes a padding error: xdr_encode_fhandle() and unx_marshal(). --- fs/nfs/nfs3xdr.c | 4 +--- fs/nfs/nfs4xdr.c | 2 +- include/linux/sunrpc/xdr.h | 2 +- net/sunrpc/auth_unix.c | 7 ++----- net/sunrpc/clnt.c | 3 --- net/sunrpc/xdr.c | 2 +- 6 files changed, 6 insertions(+), 14 deletions(-) diff -puN fs/nfs/nfs3xdr.c~nfs-rpc-remove-redundant-memset fs/nfs/nfs3xdr.c --- 25/fs/nfs/nfs3xdr.c~nfs-rpc-remove-redundant-memset 2004-02-29 14:57:11.000000000 -0800 +++ 25-akpm/fs/nfs/nfs3xdr.c 2004-02-29 14:57:11.000000000 -0800 @@ -103,9 +103,7 @@ static struct { static inline u32 * xdr_encode_fhandle(u32 *p, struct nfs_fh *fh) { - *p++ = htonl(fh->size); - memcpy(p, fh->data, fh->size); - return p + XDR_QUADLEN(fh->size); + return xdr_encode_array(p, fh->data, fh->size); } static inline u32 * diff -puN fs/nfs/nfs4xdr.c~nfs-rpc-remove-redundant-memset fs/nfs/nfs4xdr.c --- 25/fs/nfs/nfs4xdr.c~nfs-rpc-remove-redundant-memset 2004-02-29 14:57:11.000000000 -0800 +++ 25-akpm/fs/nfs/nfs4xdr.c 2004-02-29 14:57:11.000000000 -0800 @@ -324,7 +324,7 @@ encode_compound_hdr(struct xdr_stream *x dprintk("encode_compound: tag=%.*s\n", (int)hdr->taglen, hdr->tag); BUG_ON(hdr->taglen > NFS4_MAXTAGLEN); - RESERVE_SPACE(12+XDR_QUADLEN(hdr->taglen)); + RESERVE_SPACE(12+(XDR_QUADLEN(hdr->taglen)<<2)); WRITE32(hdr->taglen); WRITEMEM(hdr->tag, hdr->taglen); WRITE32(NFS4_MINOR_VERSION); diff -puN include/linux/sunrpc/xdr.h~nfs-rpc-remove-redundant-memset include/linux/sunrpc/xdr.h --- 25/include/linux/sunrpc/xdr.h~nfs-rpc-remove-redundant-memset 2004-02-29 14:57:11.000000000 -0800 +++ 25-akpm/include/linux/sunrpc/xdr.h 2004-02-29 14:57:11.000000000 -0800 @@ -87,7 +87,7 @@ struct xdr_buf { /* * Miscellaneous XDR helper functions */ -u32 * xdr_encode_array(u32 *p, const char *s, unsigned int len); +u32 * xdr_encode_array(u32 *p, const void *s, unsigned int len); u32 * xdr_encode_string(u32 *p, const char *s); u32 * xdr_decode_string(u32 *p, char **sp, int *lenp, int maxlen); u32 * xdr_decode_string_inplace(u32 *p, char **sp, int *lenp, int maxlen); diff -puN net/sunrpc/auth_unix.c~nfs-rpc-remove-redundant-memset net/sunrpc/auth_unix.c --- 25/net/sunrpc/auth_unix.c~nfs-rpc-remove-redundant-memset 2004-02-29 14:57:11.000000000 -0800 +++ 25-akpm/net/sunrpc/auth_unix.c 2004-02-29 14:57:11.000000000 -0800 @@ -149,7 +149,7 @@ unx_marshal(struct rpc_task *task, u32 * struct rpc_clnt *clnt = task->tk_client; struct unx_cred *cred = (struct unx_cred *) task->tk_msg.rpc_cred; u32 *base, *hold; - int i, n; + int i; *p++ = htonl(RPC_AUTH_UNIX); base = p++; @@ -158,10 +158,7 @@ unx_marshal(struct rpc_task *task, u32 * /* * Copy the UTS nodename captured when the client was created. */ - n = clnt->cl_nodelen; - *p++ = htonl(n); - memcpy(p, clnt->cl_nodename, n); - p += (n + 3) >> 2; + p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen); /* Note: we don't use real uid if it involves raising privilege */ if (ruid && cred->uc_puid != 0 && cred->uc_pgid != 0) { diff -puN net/sunrpc/clnt.c~nfs-rpc-remove-redundant-memset net/sunrpc/clnt.c --- 25/net/sunrpc/clnt.c~nfs-rpc-remove-redundant-memset 2004-02-29 14:57:11.000000000 -0800 +++ 25-akpm/net/sunrpc/clnt.c 2004-02-29 14:57:11.000000000 -0800 @@ -611,9 +611,6 @@ call_encode(struct rpc_task *task) rcvbuf->page_len = 0; rcvbuf->len = bufsiz; - /* Zero buffer so we have automatic zero-padding of opaque & string */ - memset(task->tk_buffer, 0, bufsiz); - /* Encode header and provided arguments */ encode = task->tk_msg.rpc_proc->p_encode; if (!(p = call_header(task))) { diff -puN net/sunrpc/xdr.c~nfs-rpc-remove-redundant-memset net/sunrpc/xdr.c --- 25/net/sunrpc/xdr.c~nfs-rpc-remove-redundant-memset 2004-02-29 14:57:11.000000000 -0800 +++ 25-akpm/net/sunrpc/xdr.c 2004-02-29 14:57:11.000000000 -0800 @@ -54,7 +54,7 @@ xdr_decode_netobj(u32 *p, struct xdr_net } u32 * -xdr_encode_array(u32 *p, const char *array, unsigned int len) +xdr_encode_array(u32 *p, const void *array, unsigned int len) { int quadlen = XDR_QUADLEN(len); _