Linux NFS development
 help / color / mirror / Atom feed
* [PATCH][next] nfsd: remove redundant assignments to variable len
@ 2023-06-21 14:52 Colin Ian King
  2023-06-21 15:16 ` Chuck Lever III
  2023-06-21 19:04 ` Jeff Layton
  0 siblings, 2 replies; 3+ messages in thread
From: Colin Ian King @ 2023-06-21 14:52 UTC (permalink / raw)
  To: Chuck Lever, Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo,
	Tom Talpey, linux-nfs
  Cc: kernel-janitors, linux-kernel

There are a few assignments to variable len where the value is not
being read and so the assignments are redundant and can be removed.
In one case, the variable len can be removed completely. Cleans up
4 clang scan warnings of the form:

fs/nfsd/export.c:100:7: warning: Although the value stored to 'len'
is used in the enclosing expression, the value is never actually
read from 'len' [deadcode.DeadStores]

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 fs/nfsd/export.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index ae85257b4238..11a0eaa2f914 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -97,7 +97,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
 		goto out;
 
 	err = -EINVAL;
-	if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
+	if (qword_get(&mesg, buf, PAGE_SIZE) <= 0)
 		goto out;
 
 	err = -ENOENT;
@@ -107,7 +107,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
 	dprintk("found domain %s\n", buf);
 
 	err = -EINVAL;
-	if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
+	if (qword_get(&mesg, buf, PAGE_SIZE) <= 0)
 		goto out;
 	fsidtype = simple_strtoul(buf, &ep, 10);
 	if (*ep)
@@ -593,7 +593,6 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
 {
 	/* client path expiry [flags anonuid anongid fsid] */
 	char *buf;
-	int len;
 	int err;
 	struct auth_domain *dom = NULL;
 	struct svc_export exp = {}, *expp;
@@ -609,8 +608,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
 
 	/* client */
 	err = -EINVAL;
-	len = qword_get(&mesg, buf, PAGE_SIZE);
-	if (len <= 0)
+	if (qword_get(&mesg, buf, PAGE_SIZE) <= 0)
 		goto out;
 
 	err = -ENOENT;
@@ -620,7 +618,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
 
 	/* path */
 	err = -EINVAL;
-	if ((len = qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
+	if (qword_get(&mesg, buf, PAGE_SIZE) <= 0)
 		goto out1;
 
 	err = kern_path(buf, 0, &exp.ex_path);
@@ -665,7 +663,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
 			goto out3;
 		exp.ex_fsid = an_int;
 
-		while ((len = qword_get(&mesg, buf, PAGE_SIZE)) > 0) {
+		while (qword_get(&mesg, buf, PAGE_SIZE) > 0) {
 			if (strcmp(buf, "fsloc") == 0)
 				err = fsloc_parse(&mesg, buf, &exp.ex_fslocs);
 			else if (strcmp(buf, "uuid") == 0)
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] nfsd: remove redundant assignments to variable len
  2023-06-21 14:52 [PATCH][next] nfsd: remove redundant assignments to variable len Colin Ian King
@ 2023-06-21 15:16 ` Chuck Lever III
  2023-06-21 19:04 ` Jeff Layton
  1 sibling, 0 replies; 3+ messages in thread
From: Chuck Lever III @ 2023-06-21 15:16 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Linux NFS Mailing List, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org



> On Jun 21, 2023, at 10:52 AM, Colin Ian King <colin.i.king@gmail.com> wrote:
> 
> There are a few assignments to variable len where the value is not
> being read and so the assignments are redundant and can be removed.
> In one case, the variable len can be removed completely. Cleans up
> 4 clang scan warnings of the form:
> 
> fs/nfsd/export.c:100:7: warning: Although the value stored to 'len'
> is used in the enclosing expression, the value is never actually
> read from 'len' [deadcode.DeadStores]
> 
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
> fs/nfsd/export.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
> index ae85257b4238..11a0eaa2f914 100644
> --- a/fs/nfsd/export.c
> +++ b/fs/nfsd/export.c
> @@ -97,7 +97,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
> goto out;
> 
> err = -EINVAL;
> - if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
> + if (qword_get(&mesg, buf, PAGE_SIZE) <= 0)
> goto out;
> 
> err = -ENOENT;
> @@ -107,7 +107,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
> dprintk("found domain %s\n", buf);
> 
> err = -EINVAL;
> - if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
> + if (qword_get(&mesg, buf, PAGE_SIZE) <= 0)
> goto out;
> fsidtype = simple_strtoul(buf, &ep, 10);
> if (*ep)
> @@ -593,7 +593,6 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
> {
> /* client path expiry [flags anonuid anongid fsid] */
> char *buf;
> - int len;
> int err;
> struct auth_domain *dom = NULL;
> struct svc_export exp = {}, *expp;
> @@ -609,8 +608,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
> 
> /* client */
> err = -EINVAL;
> - len = qword_get(&mesg, buf, PAGE_SIZE);
> - if (len <= 0)
> + if (qword_get(&mesg, buf, PAGE_SIZE) <= 0)
> goto out;
> 
> err = -ENOENT;
> @@ -620,7 +618,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
> 
> /* path */
> err = -EINVAL;
> - if ((len = qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
> + if (qword_get(&mesg, buf, PAGE_SIZE) <= 0)
> goto out1;
> 
> err = kern_path(buf, 0, &exp.ex_path);
> @@ -665,7 +663,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
> goto out3;
> exp.ex_fsid = an_int;
> 
> - while ((len = qword_get(&mesg, buf, PAGE_SIZE)) > 0) {
> + while (qword_get(&mesg, buf, PAGE_SIZE) > 0) {
> if (strcmp(buf, "fsloc") == 0)
> err = fsloc_parse(&mesg, buf, &exp.ex_fslocs);
> else if (strcmp(buf, "uuid") == 0)
> -- 
> 2.39.2

Thanks, applied to nfsd-next.


--
Chuck Lever



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] nfsd: remove redundant assignments to variable len
  2023-06-21 14:52 [PATCH][next] nfsd: remove redundant assignments to variable len Colin Ian King
  2023-06-21 15:16 ` Chuck Lever III
@ 2023-06-21 19:04 ` Jeff Layton
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Layton @ 2023-06-21 19:04 UTC (permalink / raw)
  To: Colin Ian King, Chuck Lever, Neil Brown, Olga Kornievskaia,
	Dai Ngo, Tom Talpey, linux-nfs
  Cc: kernel-janitors, linux-kernel

On Wed, 2023-06-21 at 15:52 +0100, Colin Ian King wrote:
> There are a few assignments to variable len where the value is not
> being read and so the assignments are redundant and can be removed.
> In one case, the variable len can be removed completely. Cleans up
> 4 clang scan warnings of the form:
> 
> fs/nfsd/export.c:100:7: warning: Although the value stored to 'len'
> is used in the enclosing expression, the value is never actually
> read from 'len' [deadcode.DeadStores]
> 
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>  fs/nfsd/export.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
> index ae85257b4238..11a0eaa2f914 100644
> --- a/fs/nfsd/export.c
> +++ b/fs/nfsd/export.c
> @@ -97,7 +97,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
>  		goto out;
>  
>  	err = -EINVAL;
> -	if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
> +	if (qword_get(&mesg, buf, PAGE_SIZE) <= 0)
>  		goto out;
>  
>  	err = -ENOENT;
> @@ -107,7 +107,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
>  	dprintk("found domain %s\n", buf);
>  
>  	err = -EINVAL;
> -	if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
> +	if (qword_get(&mesg, buf, PAGE_SIZE) <= 0)
>  		goto out;
>  	fsidtype = simple_strtoul(buf, &ep, 10);
>  	if (*ep)
> @@ -593,7 +593,6 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
>  {
>  	/* client path expiry [flags anonuid anongid fsid] */
>  	char *buf;
> -	int len;
>  	int err;
>  	struct auth_domain *dom = NULL;
>  	struct svc_export exp = {}, *expp;
> @@ -609,8 +608,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
>  
>  	/* client */
>  	err = -EINVAL;
> -	len = qword_get(&mesg, buf, PAGE_SIZE);
> -	if (len <= 0)
> +	if (qword_get(&mesg, buf, PAGE_SIZE) <= 0)
>  		goto out;
>  
>  	err = -ENOENT;
> @@ -620,7 +618,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
>  
>  	/* path */
>  	err = -EINVAL;
> -	if ((len = qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
> +	if (qword_get(&mesg, buf, PAGE_SIZE) <= 0)
>  		goto out1;
>  
>  	err = kern_path(buf, 0, &exp.ex_path);
> @@ -665,7 +663,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
>  			goto out3;
>  		exp.ex_fsid = an_int;
>  
> -		while ((len = qword_get(&mesg, buf, PAGE_SIZE)) > 0) {
> +		while (qword_get(&mesg, buf, PAGE_SIZE) > 0) {
>  			if (strcmp(buf, "fsloc") == 0)
>  				err = fsloc_parse(&mesg, buf, &exp.ex_fslocs);
>  			else if (strcmp(buf, "uuid") == 0)

Reviewed-by: Jeff Layton <jlayton@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-21 19:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-21 14:52 [PATCH][next] nfsd: remove redundant assignments to variable len Colin Ian King
2023-06-21 15:16 ` Chuck Lever III
2023-06-21 19:04 ` Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox