From: Trond Myklebust Date: Fri, 15 Aug 2008 17:02:38 -0400 SUNRPC: constify rpc_clnt fields cl_server and cl_protname Signed-off-by: Trond Myklebust --- include/linux/sunrpc/clnt.h | 8 ++++---- net/sunrpc/clnt.c | 12 +++++++----- net/sunrpc/rpcb_clnt.c | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 619600e..488cccb 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -34,8 +34,8 @@ struct rpc_clnt { cl_vers, /* RPC version number */ cl_maxproc; /* max procedure number */ - char * cl_server; /* server machine name */ - char * cl_protname; /* protocol name */ + const char *cl_server; /* server machine name */ + const char *cl_protname; /* protocol name */ struct rpc_auth * cl_auth; /* authenticator */ struct rpc_stat * cl_stats; /* per-program statistics */ struct rpc_iostats * cl_metrics; /* per-client statistics */ @@ -91,7 +91,7 @@ struct rpc_procinfo { unsigned int p_count; /* call count */ unsigned int p_timer; /* Which RTT timer to use */ u32 p_statidx; /* Which procedure to account */ - char * p_name; /* name of procedure */ + const char * p_name; /* name of procedure */ }; #ifdef __KERNEL__ @@ -102,7 +102,7 @@ struct rpc_create_args { size_t addrsize; struct sockaddr *saddress; const struct rpc_timeout *timeout; - char *servername; + const char *servername; struct rpc_program *program; u32 version; rpc_authflavor_t authflavor; diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 26d8442..d226ea3 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -128,6 +128,7 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru struct rpc_version *version; struct rpc_clnt *clnt = NULL; struct rpc_auth *auth; + char *buf; int err; size_t len; @@ -160,15 +161,16 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru goto out_err; clnt->cl_parent = clnt; - clnt->cl_server = clnt->cl_inline_name; + buf = clnt->cl_inline_name; if (len > sizeof(clnt->cl_inline_name)) { - char *buf = kmalloc(len, GFP_KERNEL); - if (buf != NULL) - clnt->cl_server = buf; + char *new = kmalloc(len, GFP_KERNEL); + if (new != NULL) + buf = new; else len = sizeof(clnt->cl_inline_name); } - strlcpy(clnt->cl_server, args->servername, len); + strlcpy(buf, args->servername, len); + clnt->cl_server = buf; clnt->cl_xprt = xprt; clnt->cl_procinfo = version->procs; diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c index 0a22f00..9c1a4c3 100644 --- a/net/sunrpc/rpcb_clnt.c +++ b/net/sunrpc/rpcb_clnt.c @@ -146,7 +146,7 @@ static struct rpc_clnt *rpcb_create_local(struct sockaddr *addr, return rpc_create(&args); } -static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr, +static struct rpc_clnt *rpcb_create(const char *hostname, struct sockaddr *srvaddr, size_t salen, int proto, u32 version) { struct rpc_create_args args = {