[PATCH 2/5][next] bcachefs: remove redundant initialization of pointer dst

Colin Ian King posted 5 patches 2 years, 3 months ago
[PATCH 2/5][next] bcachefs: remove redundant initialization of pointer dst
Posted by Colin Ian King 2 years, 3 months ago
The pointer dst is being initialized with a value that is never read,
it is being re-assigned later on when it is used in a while-loop
The initialization is redundant and can be removed.

Cleans up clang-scan build warning:
fs/bcachefs/disk_groups.c:186:30: warning: Value stored to 'dst' during
its initialization is never read [deadcode.DeadStores]

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 fs/bcachefs/disk_groups.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/bcachefs/disk_groups.c b/fs/bcachefs/disk_groups.c
index f36472c4a781..9fa8d7d49f3e 100644
--- a/fs/bcachefs/disk_groups.c
+++ b/fs/bcachefs/disk_groups.c
@@ -183,8 +183,7 @@ int bch2_sb_disk_groups_to_cpu(struct bch_fs *c)
 
 	for (i = 0; i < c->disk_sb.sb->nr_devices; i++) {
 		struct bch_member *m = mi->members + i;
-		struct bch_disk_group_cpu *dst =
-			&cpu_g->entries[BCH_MEMBER_GROUP(m)];
+		struct bch_disk_group_cpu *dst;
 
 		if (!bch2_member_exists(m))
 			continue;
-- 
2.39.2
Re: [PATCH 2/5][next] bcachefs: remove redundant initialization of pointer dst
Posted by Brian Foster 2 years, 3 months ago
On Tue, Sep 12, 2023 at 01:37:41PM +0100, Colin Ian King wrote:
> The pointer dst is being initialized with a value that is never read,
> it is being re-assigned later on when it is used in a while-loop
> The initialization is redundant and can be removed.
> 
> Cleans up clang-scan build warning:
> fs/bcachefs/disk_groups.c:186:30: warning: Value stored to 'dst' during
> its initialization is never read [deadcode.DeadStores]
> 
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>  fs/bcachefs/disk_groups.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/bcachefs/disk_groups.c b/fs/bcachefs/disk_groups.c
> index f36472c4a781..9fa8d7d49f3e 100644
> --- a/fs/bcachefs/disk_groups.c
> +++ b/fs/bcachefs/disk_groups.c
> @@ -183,8 +183,7 @@ int bch2_sb_disk_groups_to_cpu(struct bch_fs *c)
>  
>  	for (i = 0; i < c->disk_sb.sb->nr_devices; i++) {
>  		struct bch_member *m = mi->members + i;
> -		struct bch_disk_group_cpu *dst =
> -			&cpu_g->entries[BCH_MEMBER_GROUP(m)];
> +		struct bch_disk_group_cpu *dst;

Nit: kind of seems like this variable could just be lifted to the top of
the function given that it's used in two loops, but the patch seems fine
to me either way.

Brian

>  
>  		if (!bch2_member_exists(m))
>  			continue;
> -- 
> 2.39.2
>