linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: Remove dead code
@ 2022-01-28 11:50 Muhammad Usama Anjum
  2022-02-01 14:05 ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Muhammad Usama Anjum @ 2022-01-28 11:50 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba, Qu Wenruo
  Cc: Muhammad Usama Anjum, kernel, kernel-janitors, linux-btrfs, linux-kernel

Local variable stop_loop is assigned only once, to a constant value 0,
making it effectively constant through out its scope. This constant
variable is guarding deadcode. The two if conditions can never be true.
Remove the variable and make the logic simple.

Fixes: 585f784357d8 ("btrfs: use scrub_simple_mirror() to handle RAID56 data stripe scrub")
Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 fs/btrfs/scrub.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 4baa8e43d585b..26bbe93c3aa3c 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -3533,7 +3533,6 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
 	u64 offset;	/* Offset inside the chunk */
 	u64 stripe_logical;
 	u64 stripe_end;
-	int stop_loop = 0;
 
 	path = btrfs_alloc_path();
 	if (!path)
@@ -3652,14 +3651,8 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
 		logical += increment;
 		physical += map->stripe_len;
 		spin_lock(&sctx->stat_lock);
-		if (stop_loop)
-			sctx->stat.last_physical = map->stripes[stripe_index].physical +
-						   dev_extent_len;
-		else
-			sctx->stat.last_physical = physical;
+		sctx->stat.last_physical = physical;
 		spin_unlock(&sctx->stat_lock);
-		if (stop_loop)
-			break;
 	}
 out:
 	/* push queued extents */
-- 
2.30.2


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

* Re: [PATCH] btrfs: Remove dead code
  2022-01-28 11:50 [PATCH] btrfs: Remove dead code Muhammad Usama Anjum
@ 2022-02-01 14:05 ` David Sterba
  0 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2022-02-01 14:05 UTC (permalink / raw)
  To: Muhammad Usama Anjum
  Cc: Chris Mason, Josef Bacik, David Sterba, Qu Wenruo, kernel,
	kernel-janitors, linux-btrfs, linux-kernel

On Fri, Jan 28, 2022 at 04:50:27PM +0500, Muhammad Usama Anjum wrote:
> Local variable stop_loop is assigned only once, to a constant value 0,
> making it effectively constant through out its scope. This constant
> variable is guarding deadcode. The two if conditions can never be true.
> Remove the variable and make the logic simple.
> 
> Fixes: 585f784357d8 ("btrfs: use scrub_simple_mirror() to handle RAID56 data stripe scrub")

Thanks, this patch is still only in for-next so the change can be folded
into it.

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

* Re: [PATCH] btrfs: remove dead code
  2013-11-29 17:01 [PATCH] btrfs: remove " Michal Nazarewicz
@ 2013-11-29 20:00 ` Filipe David Manana
  0 siblings, 0 replies; 4+ messages in thread
From: Filipe David Manana @ 2013-11-29 20:00 UTC (permalink / raw)
  To: Michal Nazarewicz; +Cc: Chris Mason, linux-btrfs, linux-kernel

On Fri, Nov 29, 2013 at 5:01 PM, Michal Nazarewicz <mpn@google.com> wrote:
> From: Michal Nazarewicz <mina86@mina86.com>
>
> [commit 8185554d: fix incorrect inode acl reset] introduced a dead
> code by adding a condition which can never be true to an else
> branch.  The condition can never be true because it is already
> checked by a previous if statement which causes function to return.
>
> Signed-off-by: Michal Nazarewicz <mina86@mina86.com>

Reviewed-By: Filipe David Borba Manana <fdmanana@gmail.com>

> ---
>  fs/btrfs/acl.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
> index 0890c83..460f36b 100644
> --- a/fs/btrfs/acl.c
> +++ b/fs/btrfs/acl.c
> @@ -225,13 +225,8 @@ int btrfs_init_acl(struct btrfs_trans_handle *trans,
>                 ret = posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
>                 if (ret < 0)
>                         return ret;
> -
> -               if (ret > 0) {
> -                       /* we need an acl */
> +               if (ret > 0) /* we need an acl */
>                         ret = btrfs_set_acl(trans, inode, acl, ACL_TYPE_ACCESS);
> -               } else if (ret < 0) {
> -                       cache_no_acl(inode);
> -               }
>         } else {
>                 cache_no_acl(inode);
>         }
> --
> 1.8.4.1
>



-- 
Filipe David Manana,

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

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

* [PATCH] btrfs: remove dead code
@ 2013-11-29 17:01 Michal Nazarewicz
  2013-11-29 20:00 ` Filipe David Manana
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Nazarewicz @ 2013-11-29 17:01 UTC (permalink / raw)
  To: Chris Mason, Filipe David Borba Manana; +Cc: linux-btrfs, linux-kernel

From: Michal Nazarewicz <mina86@mina86.com>

[commit 8185554d: fix incorrect inode acl reset] introduced a dead
code by adding a condition which can never be true to an else
branch.  The condition can never be true because it is already
checked by a previous if statement which causes function to return.

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
---
 fs/btrfs/acl.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
index 0890c83..460f36b 100644
--- a/fs/btrfs/acl.c
+++ b/fs/btrfs/acl.c
@@ -225,13 +225,8 @@ int btrfs_init_acl(struct btrfs_trans_handle *trans,
 		ret = posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
 		if (ret < 0)
 			return ret;
-
-		if (ret > 0) {
-			/* we need an acl */
+		if (ret > 0) /* we need an acl */
 			ret = btrfs_set_acl(trans, inode, acl, ACL_TYPE_ACCESS);
-		} else if (ret < 0) {
-			cache_no_acl(inode);
-		}
 	} else {
 		cache_no_acl(inode);
 	}
-- 
1.8.4.1


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

end of thread, other threads:[~2022-02-01 14:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-28 11:50 [PATCH] btrfs: Remove dead code Muhammad Usama Anjum
2022-02-01 14:05 ` David Sterba
  -- strict thread matches above, loose matches on Subject: below --
2013-11-29 17:01 [PATCH] btrfs: remove " Michal Nazarewicz
2013-11-29 20:00 ` Filipe David Manana

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).