linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] afs: remove redundant assignment to variable ret
@ 2020-07-22 15:22 Colin King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2020-07-22 15:22 UTC (permalink / raw)
  To: David Howells, linux-afs; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The variable ret is being assigned a value that is never read because
the next statment returns from the function. The assignment is redundant
and can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 fs/afs/server.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/afs/server.c b/fs/afs/server.c
index e82e452e2612..429cd226e4da 100644
--- a/fs/afs/server.c
+++ b/fs/afs/server.c
@@ -701,7 +701,6 @@ bool afs_check_server_record(struct afs_operation *op, struct afs_server *server
 	retries++;
 	if (retries == 4) {
 		_leave(" = f [stale]");
-		ret = -ESTALE;
 		return false;
 	}
 	goto retry;
-- 
2.27.0


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

* [PATCH] afs: remove redundant assignment to variable ret
@ 2020-05-27 12:06 Colin King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2020-05-27 12:06 UTC (permalink / raw)
  To: David Howells, linux-afs; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The variable ret is being assigned a value that is never read. The
assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 fs/afs/dir.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index d1e1caa23c8b..5608665ccb71 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -579,7 +579,6 @@ static int afs_do_lookup_one(struct inode *dir, struct dentry *dentry,
 		return ret;
 	}
 
-	ret = -ENOENT;
 	if (!cookie.found) {
 		_leave(" = -ENOENT [not found]");
 		return -ENOENT;
-- 
2.25.1


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

* Re: [PATCH] afs: remove redundant assignment to variable ret
  2019-05-11 12:36 Colin King
  2019-05-11 15:35 ` Joe Perches
  2019-05-12  6:55 ` David Howells
@ 2019-05-12  6:56 ` David Howells
  2 siblings, 0 replies; 6+ messages in thread
From: David Howells @ 2019-05-12  6:56 UTC (permalink / raw)
  To: Joe Perches
  Cc: dhowells, Colin King, linux-afs, kernel-janitors, linux-kernel

Joe Perches <joe@perches.com> wrote:

> @@ -71,11 +71,9 @@ static int afs_xattr_get_acl(const struct xattr_handler *handler,
>  	if (ret == 0) {
>  		ret = acl->size;
>  		if (size > 0) {
> -			ret = -ERANGE;
>  			if (acl->size > size)
>  				return -ERANGE;
>  			memcpy(buffer, acl->data, acl->size);
> -			ret = acl->size;
>  		}
>  		kfree(acl);
>  	}

This is also the wrong solution.  See my reply to Colin.

David

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

* Re: [PATCH] afs: remove redundant assignment to variable ret
  2019-05-11 12:36 Colin King
  2019-05-11 15:35 ` Joe Perches
@ 2019-05-12  6:55 ` David Howells
  2019-05-12  6:56 ` David Howells
  2 siblings, 0 replies; 6+ messages in thread
From: David Howells @ 2019-05-12  6:55 UTC (permalink / raw)
  To: Colin King; +Cc: dhowells, linux-afs, kernel-janitors, linux-kernel

Colin King <colin.king@canonical.com> wrote:

> The variable ret is being assigned a value however this is never
> read and later it is being reassigned to a new value. The assignment
> is redundant and hence can be removed.

No.

>  	if (ret == 0) {
>  		ret = acl->size;
>  		if (size > 0) {
> -			ret = -ERANGE;
>  			if (acl->size > size)
>  				return -ERANGE;
>  			memcpy(buffer, acl->data, acl->size);

This is the wrong solution.  acl and key need releasing, so the return should
be a goto.

David

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

* Re: [PATCH] afs: remove redundant assignment to variable ret
  2019-05-11 12:36 Colin King
@ 2019-05-11 15:35 ` Joe Perches
  2019-05-12  6:55 ` David Howells
  2019-05-12  6:56 ` David Howells
  2 siblings, 0 replies; 6+ messages in thread
From: Joe Perches @ 2019-05-11 15:35 UTC (permalink / raw)
  To: Colin King, David Howells, linux-afs; +Cc: kernel-janitors, linux-kernel

On Sat, 2019-05-11 at 13:36 +0100, Colin King wrote:
> The variable ret is being assigned a value however this is never
> read and later it is being reassigned to a new value. The assignment
> is redundant and hence can be removed.
[]
> diff --git a/fs/afs/xattr.c b/fs/afs/xattr.c
[]
> @@ -71,7 +71,6 @@ static int afs_xattr_get_acl(const struct xattr_handler *handler,
>  	if (ret == 0) {
>  		ret = acl->size;
>  		if (size > 0) {
> -			ret = -ERANGE;
>  			if (acl->size > size)
>  				return -ERANGE;
>  			memcpy(buffer, acl->data, acl->size);

It looks like the ret = acl->size immediately
after the memcpy should be removed as well.
---
 fs/afs/xattr.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/afs/xattr.c b/fs/afs/xattr.c
index c81f85003fc7..e21de2f166a4 100644
--- a/fs/afs/xattr.c
+++ b/fs/afs/xattr.c
@@ -71,11 +71,9 @@ static int afs_xattr_get_acl(const struct xattr_handler *handler,
 	if (ret == 0) {
 		ret = acl->size;
 		if (size > 0) {
-			ret = -ERANGE;
 			if (acl->size > size)
 				return -ERANGE;
 			memcpy(buffer, acl->data, acl->size);
-			ret = acl->size;
 		}
 		kfree(acl);
 	}



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

* [PATCH] afs: remove redundant assignment to variable ret
@ 2019-05-11 12:36 Colin King
  2019-05-11 15:35 ` Joe Perches
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Colin King @ 2019-05-11 12:36 UTC (permalink / raw)
  To: David Howells, linux-afs; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The variable ret is being assigned a value however this is never
read and later it is being reassigned to a new value. The assignment
is redundant and hence can be removed.

Addresses-Coverity: ("Unused Value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 fs/afs/xattr.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/afs/xattr.c b/fs/afs/xattr.c
index c81f85003fc7..25cb7ad4fca3 100644
--- a/fs/afs/xattr.c
+++ b/fs/afs/xattr.c
@@ -71,7 +71,6 @@ static int afs_xattr_get_acl(const struct xattr_handler *handler,
 	if (ret == 0) {
 		ret = acl->size;
 		if (size > 0) {
-			ret = -ERANGE;
 			if (acl->size > size)
 				return -ERANGE;
 			memcpy(buffer, acl->data, acl->size);
-- 
2.20.1


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

end of thread, other threads:[~2020-07-22 15:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22 15:22 [PATCH] afs: remove redundant assignment to variable ret Colin King
  -- strict thread matches above, loose matches on Subject: below --
2020-05-27 12:06 Colin King
2019-05-11 12:36 Colin King
2019-05-11 15:35 ` Joe Perches
2019-05-12  6:55 ` David Howells
2019-05-12  6:56 ` David Howells

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).