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 | 4 ++-- net/sunrpc/clnt.c | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 619600e..8984708 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 */ diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index a23859d..cf52cbd 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;