All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: remove redundant assignment and check on variable ret
@ 2017-05-06 22:01 ` Colin King
  0 siblings, 0 replies; 8+ messages in thread
From: Colin King @ 2017-05-06 22:01 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba, linux-btrfs; +Cc: kernel-janitors

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

Variable ret is assigned to zero and is always zero throughout the
function.  Thus the check for ret being less than zero is always
false and so mapping_set_error always has an -EIO error passed to
it.  Hence we can remove the redundant assignment and check on ret.

Detected by CoverityScan, CID#1414312 ("Logically dead code")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 fs/btrfs/extent_io.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index d8da3edf2ac3..7922cd34ba82 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2447,7 +2447,6 @@ void end_extent_writepage(struct page *page, int err, u64 start, u64 end)
 {
 	int uptodate = (err == 0);
 	struct extent_io_tree *tree;
-	int ret = 0;
 
 	tree = &BTRFS_I(page->mapping->host)->io_tree;
 
@@ -2458,8 +2457,7 @@ void end_extent_writepage(struct page *page, int err, u64 start, u64 end)
 	if (!uptodate) {
 		ClearPageUptodate(page);
 		SetPageError(page);
-		ret = ret < 0 ? ret : -EIO;
-		mapping_set_error(page->mapping, ret);
+		mapping_set_error(page->mapping, -EIO);
 	}
 }
 
-- 
2.11.0


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

* [PATCH] btrfs: remove redundant assignment and check on variable ret
@ 2017-05-06 22:01 ` Colin King
  0 siblings, 0 replies; 8+ messages in thread
From: Colin King @ 2017-05-06 22:01 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba, linux-btrfs; +Cc: kernel-janitors

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

Variable ret is assigned to zero and is always zero throughout the
function.  Thus the check for ret being less than zero is always
false and so mapping_set_error always has an -EIO error passed to
it.  Hence we can remove the redundant assignment and check on ret.

Detected by CoverityScan, CID#1414312 ("Logically dead code")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 fs/btrfs/extent_io.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index d8da3edf2ac3..7922cd34ba82 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2447,7 +2447,6 @@ void end_extent_writepage(struct page *page, int err, u64 start, u64 end)
 {
 	int uptodate = (err = 0);
 	struct extent_io_tree *tree;
-	int ret = 0;
 
 	tree = &BTRFS_I(page->mapping->host)->io_tree;
 
@@ -2458,8 +2457,7 @@ void end_extent_writepage(struct page *page, int err, u64 start, u64 end)
 	if (!uptodate) {
 		ClearPageUptodate(page);
 		SetPageError(page);
-		ret = ret < 0 ? ret : -EIO;
-		mapping_set_error(page->mapping, ret);
+		mapping_set_error(page->mapping, -EIO);
 	}
 }
 
-- 
2.11.0


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

* Re: [PATCH] btrfs: remove redundant assignment and check on variable ret
  2017-05-06 22:01 ` Colin King
@ 2017-05-09 15:28   ` David Sterba
  -1 siblings, 0 replies; 8+ messages in thread
From: David Sterba @ 2017-05-09 15:28 UTC (permalink / raw)
  To: Colin King
  Cc: Chris Mason, Josef Bacik, David Sterba, linux-btrfs, kernel-janitors

On Sat, May 06, 2017 at 11:01:05PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Variable ret is assigned to zero and is always zero throughout the
> function.  Thus the check for ret being less than zero is always
> false and so mapping_set_error always has an -EIO error passed to
> it.  Hence we can remove the redundant assignment and check on ret.
> 
> Detected by CoverityScan, CID#1414312 ("Logically dead code")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Reviewed-by: David Sterba <dsterba@suse.com>

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

* Re: [PATCH] btrfs: remove redundant assignment and check on variable ret
@ 2017-05-09 15:28   ` David Sterba
  0 siblings, 0 replies; 8+ messages in thread
From: David Sterba @ 2017-05-09 15:28 UTC (permalink / raw)
  To: Colin King
  Cc: Chris Mason, Josef Bacik, David Sterba, linux-btrfs, kernel-janitors

On Sat, May 06, 2017 at 11:01:05PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Variable ret is assigned to zero and is always zero throughout the
> function.  Thus the check for ret being less than zero is always
> false and so mapping_set_error always has an -EIO error passed to
> it.  Hence we can remove the redundant assignment and check on ret.
> 
> Detected by CoverityScan, CID#1414312 ("Logically dead code")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Reviewed-by: David Sterba <dsterba@suse.com>

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

* Re: [PATCH] btrfs: remove redundant assignment and check on variable ret
  2017-05-06 22:01 ` Colin King
@ 2017-05-09 16:55   ` Liu Bo
  -1 siblings, 0 replies; 8+ messages in thread
From: Liu Bo @ 2017-05-09 16:55 UTC (permalink / raw)
  To: Colin King
  Cc: Chris Mason, Josef Bacik, David Sterba, linux-btrfs, kernel-janitors

On Sat, May 06, 2017 at 11:01:05PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Variable ret is assigned to zero and is always zero throughout the
> function.  Thus the check for ret being less than zero is always
> false and so mapping_set_error always has an -EIO error passed to
> it.  Hence we can remove the redundant assignment and check on ret.
> 
> Detected by CoverityScan, CID#1414312 ("Logically dead code")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  fs/btrfs/extent_io.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index d8da3edf2ac3..7922cd34ba82 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -2447,7 +2447,6 @@ void end_extent_writepage(struct page *page, int err, u64 start, u64 end)
>  {
>  	int uptodate = (err == 0);
>  	struct extent_io_tree *tree;
> -	int ret = 0;
>  
>  	tree = &BTRFS_I(page->mapping->host)->io_tree;
>  
> @@ -2458,8 +2457,7 @@ void end_extent_writepage(struct page *page, int err, u64 start, u64 end)
>  	if (!uptodate) {
>  		ClearPageUptodate(page);
>  		SetPageError(page);
> -		ret = ret < 0 ? ret : -EIO;
> -		mapping_set_error(page->mapping, ret);
> +		mapping_set_error(page->mapping, -EIO);

The passed 'err' should be used as what ret did, ie.
ret = err < 0 ? err : -EIO;

Thanks,

-liubo
>  	}
>  }
>  
> -- 
> 2.11.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] btrfs: remove redundant assignment and check on variable ret
@ 2017-05-09 16:55   ` Liu Bo
  0 siblings, 0 replies; 8+ messages in thread
From: Liu Bo @ 2017-05-09 16:55 UTC (permalink / raw)
  To: Colin King
  Cc: Chris Mason, Josef Bacik, David Sterba, linux-btrfs, kernel-janitors

On Sat, May 06, 2017 at 11:01:05PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Variable ret is assigned to zero and is always zero throughout the
> function.  Thus the check for ret being less than zero is always
> false and so mapping_set_error always has an -EIO error passed to
> it.  Hence we can remove the redundant assignment and check on ret.
> 
> Detected by CoverityScan, CID#1414312 ("Logically dead code")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  fs/btrfs/extent_io.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index d8da3edf2ac3..7922cd34ba82 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -2447,7 +2447,6 @@ void end_extent_writepage(struct page *page, int err, u64 start, u64 end)
>  {
>  	int uptodate = (err = 0);
>  	struct extent_io_tree *tree;
> -	int ret = 0;
>  
>  	tree = &BTRFS_I(page->mapping->host)->io_tree;
>  
> @@ -2458,8 +2457,7 @@ void end_extent_writepage(struct page *page, int err, u64 start, u64 end)
>  	if (!uptodate) {
>  		ClearPageUptodate(page);
>  		SetPageError(page);
> -		ret = ret < 0 ? ret : -EIO;
> -		mapping_set_error(page->mapping, ret);
> +		mapping_set_error(page->mapping, -EIO);

The passed 'err' should be used as what ret did, ie.
ret = err < 0 ? err : -EIO;

Thanks,

-liubo
>  	}
>  }
>  
> -- 
> 2.11.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] btrfs: remove redundant assignment and check on variable ret
  2017-05-09 16:55   ` Liu Bo
@ 2017-05-09 17:01     ` Colin Ian King
  -1 siblings, 0 replies; 8+ messages in thread
From: Colin Ian King @ 2017-05-09 17:01 UTC (permalink / raw)
  To: bo.li.liu
  Cc: Chris Mason, Josef Bacik, David Sterba, linux-btrfs, kernel-janitors

On 09/05/17 17:55, Liu Bo wrote:
> On Sat, May 06, 2017 at 11:01:05PM +0100, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Variable ret is assigned to zero and is always zero throughout the
>> function.  Thus the check for ret being less than zero is always
>> false and so mapping_set_error always has an -EIO error passed to
>> it.  Hence we can remove the redundant assignment and check on ret.
>>
>> Detected by CoverityScan, CID#1414312 ("Logically dead code")
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  fs/btrfs/extent_io.c | 4 +---
>>  1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
>> index d8da3edf2ac3..7922cd34ba82 100644
>> --- a/fs/btrfs/extent_io.c
>> +++ b/fs/btrfs/extent_io.c
>> @@ -2447,7 +2447,6 @@ void end_extent_writepage(struct page *page, int err, u64 start, u64 end)
>>  {
>>  	int uptodate = (err == 0);
>>  	struct extent_io_tree *tree;
>> -	int ret = 0;
>>  
>>  	tree = &BTRFS_I(page->mapping->host)->io_tree;
>>  
>> @@ -2458,8 +2457,7 @@ void end_extent_writepage(struct page *page, int err, u64 start, u64 end)
>>  	if (!uptodate) {
>>  		ClearPageUptodate(page);
>>  		SetPageError(page);
>> -		ret = ret < 0 ? ret : -EIO;
>> -		mapping_set_error(page->mapping, ret);
>> +		mapping_set_error(page->mapping, -EIO);
> 
> The passed 'err' should be used as what ret did, ie.
> ret = err < 0 ? err : -EIO;

Ah, so the err passed into the function should be used instead of ret,
which makes more sense. Got it. I'll send a fix for that.

Colin

> 
> Thanks,
> 
> -liubo
>>  	}
>>  }
>>  
>> -- 
>> 2.11.0
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

* Re: [PATCH] btrfs: remove redundant assignment and check on variable ret
@ 2017-05-09 17:01     ` Colin Ian King
  0 siblings, 0 replies; 8+ messages in thread
From: Colin Ian King @ 2017-05-09 17:01 UTC (permalink / raw)
  To: bo.li.liu
  Cc: Chris Mason, Josef Bacik, David Sterba, linux-btrfs, kernel-janitors

On 09/05/17 17:55, Liu Bo wrote:
> On Sat, May 06, 2017 at 11:01:05PM +0100, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Variable ret is assigned to zero and is always zero throughout the
>> function.  Thus the check for ret being less than zero is always
>> false and so mapping_set_error always has an -EIO error passed to
>> it.  Hence we can remove the redundant assignment and check on ret.
>>
>> Detected by CoverityScan, CID#1414312 ("Logically dead code")
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  fs/btrfs/extent_io.c | 4 +---
>>  1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
>> index d8da3edf2ac3..7922cd34ba82 100644
>> --- a/fs/btrfs/extent_io.c
>> +++ b/fs/btrfs/extent_io.c
>> @@ -2447,7 +2447,6 @@ void end_extent_writepage(struct page *page, int err, u64 start, u64 end)
>>  {
>>  	int uptodate = (err = 0);
>>  	struct extent_io_tree *tree;
>> -	int ret = 0;
>>  
>>  	tree = &BTRFS_I(page->mapping->host)->io_tree;
>>  
>> @@ -2458,8 +2457,7 @@ void end_extent_writepage(struct page *page, int err, u64 start, u64 end)
>>  	if (!uptodate) {
>>  		ClearPageUptodate(page);
>>  		SetPageError(page);
>> -		ret = ret < 0 ? ret : -EIO;
>> -		mapping_set_error(page->mapping, ret);
>> +		mapping_set_error(page->mapping, -EIO);
> 
> The passed 'err' should be used as what ret did, ie.
> ret = err < 0 ? err : -EIO;

Ah, so the err passed into the function should be used instead of ret,
which makes more sense. Got it. I'll send a fix for that.

Colin

> 
> Thanks,
> 
> -liubo
>>  	}
>>  }
>>  
>> -- 
>> 2.11.0
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

end of thread, other threads:[~2017-05-09 17:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-06 22:01 [PATCH] btrfs: remove redundant assignment and check on variable ret Colin King
2017-05-06 22:01 ` Colin King
2017-05-09 15:28 ` David Sterba
2017-05-09 15:28   ` David Sterba
2017-05-09 16:55 ` Liu Bo
2017-05-09 16:55   ` Liu Bo
2017-05-09 17:01   ` Colin Ian King
2017-05-09 17:01     ` Colin Ian King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.