2022-01-31 10:03:15

by Muhammad Usama Anjum

[permalink] [raw]
Subject: [PATCH] btrfs: Remove dead code

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 <[email protected]>
---
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


2022-02-07 09:35:34

by David Sterba

[permalink] [raw]
Subject: Re: [PATCH] btrfs: Remove dead code

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.