diff options
author | Kinglong Mee <kinglongmee@gmail.com> | 2015-08-30 22:53:43 -0400 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@primarydata.com> | 2015-09-01 18:19:40 -0400 |
commit | 4a3e5779cf6c6d557682b499c2190ad04c80c6fd (patch) | |
tree | ab9c928ea898d763cfc75040416d689797fc6388 | |
parent | 4a70316caef7d158445e672e146eb9f1b8c1aeee (diff) |
nfs: Remove unneeded checking of the return value from scnprintf
The return value from scnprintf always less than the buffer length.
So, result >= len always false. This patch removes those checking.
int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
{
int i;
i = vsnprintf(buf, size, fmt, args);
if (likely(i < size))
return i;
if (size != 0)
return size - 1;
return 0;
}
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
-rw-r--r-- | fs/nfs/nfs4proc.c | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 3f73539579e5..693b903b48bd 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -5014,11 +5014,10 @@ nfs4_init_nonuniform_client_string(struct nfs_client *clp) | |||
5014 | int result; | 5014 | int result; |
5015 | size_t len; | 5015 | size_t len; |
5016 | char *str; | 5016 | char *str; |
5017 | bool retried = false; | ||
5018 | 5017 | ||
5019 | if (clp->cl_owner_id != NULL) | 5018 | if (clp->cl_owner_id != NULL) |
5020 | return 0; | 5019 | return 0; |
5021 | retry: | 5020 | |
5022 | rcu_read_lock(); | 5021 | rcu_read_lock(); |
5023 | len = 14 + strlen(clp->cl_ipaddr) + 1 + | 5022 | len = 14 + strlen(clp->cl_ipaddr) + 1 + |
5024 | strlen(rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR)) + | 5023 | strlen(rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR)) + |
@@ -5046,14 +5045,6 @@ retry: | |||
5046 | rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_PROTO)); | 5045 | rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_PROTO)); |
5047 | rcu_read_unlock(); | 5046 | rcu_read_unlock(); |
5048 | 5047 | ||
5049 | /* Did something change? */ | ||
5050 | if (result >= len) { | ||
5051 | kfree(str); | ||
5052 | if (retried) | ||
5053 | return -EINVAL; | ||
5054 | retried = true; | ||
5055 | goto retry; | ||
5056 | } | ||
5057 | clp->cl_owner_id = str; | 5048 | clp->cl_owner_id = str; |
5058 | return 0; | 5049 | return 0; |
5059 | } | 5050 | } |
@@ -5085,10 +5076,6 @@ nfs4_init_uniquifier_client_string(struct nfs_client *clp) | |||
5085 | clp->rpc_ops->version, clp->cl_minorversion, | 5076 | clp->rpc_ops->version, clp->cl_minorversion, |
5086 | nfs4_client_id_uniquifier, | 5077 | nfs4_client_id_uniquifier, |
5087 | clp->cl_rpcclient->cl_nodename); | 5078 | clp->cl_rpcclient->cl_nodename); |
5088 | if (result >= len) { | ||
5089 | kfree(str); | ||
5090 | return -EINVAL; | ||
5091 | } | ||
5092 | clp->cl_owner_id = str; | 5079 | clp->cl_owner_id = str; |
5093 | return 0; | 5080 | return 0; |
5094 | } | 5081 | } |
@@ -5124,10 +5111,6 @@ nfs4_init_uniform_client_string(struct nfs_client *clp) | |||
5124 | result = scnprintf(str, len, "Linux NFSv%u.%u %s", | 5111 | result = scnprintf(str, len, "Linux NFSv%u.%u %s", |
5125 | clp->rpc_ops->version, clp->cl_minorversion, | 5112 | clp->rpc_ops->version, clp->cl_minorversion, |
5126 | clp->cl_rpcclient->cl_nodename); | 5113 | clp->cl_rpcclient->cl_nodename); |
5127 | if (result >= len) { | ||
5128 | kfree(str); | ||
5129 | return -EINVAL; | ||
5130 | } | ||
5131 | clp->cl_owner_id = str; | 5114 | clp->cl_owner_id = str; |
5132 | return 0; | 5115 | return 0; |
5133 | } | 5116 | } |