2023-09-12 15:03:00

by Colin Ian King

[permalink] [raw]
Subject: [PATCH 0/5][next] bcachefs: clean up some redundant assignments

Clean up some redundant assignments and variables based on warnings
found by clang scan build static analysis.

Colin Ian King (5):
bcachefs: remove redundant initialization of pointer d
bcachefs: remove redundant initialization of pointer dst
bcachefs: remove redundant initializations of variables start_offset
and end_offset
bcachefs: remove duplicated assignment to variable offset_into_extent
bcachefs: remove redundant pointer q

fs/bcachefs/btree_update_interior.c | 2 +-
fs/bcachefs/buckets.c | 2 +-
fs/bcachefs/disk_groups.c | 3 +--
fs/bcachefs/fs-io.c | 4 ++--
fs/bcachefs/io.c | 1 -
fs/bcachefs/quota.c | 3 ---
6 files changed, 5 insertions(+), 10 deletions(-)

--
2.39.2


2023-09-12 15:19:03

by Colin Ian King

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

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

2023-09-12 16:25:45

by Colin Ian King

[permalink] [raw]
Subject: [PATCH 5/5][next] bcachefs: remove redundant pointer q

The pointer q is being assigned a value but it is never read. The
assignment and pointer are redundant and can be removed.
Cleans up clang scan build warning:

fs/bcachefs/quota.c:813:2: warning: Value stored to 'q' is never
read [deadcode.DeadStores]

Signed-off-by: Colin Ian King <[email protected]>
---
fs/bcachefs/quota.c | 3 ---
1 file changed, 3 deletions(-)

diff --git a/fs/bcachefs/quota.c b/fs/bcachefs/quota.c
index ca99772aedc6..719c4c9fc51f 100644
--- a/fs/bcachefs/quota.c
+++ b/fs/bcachefs/quota.c
@@ -786,7 +786,6 @@ static int bch2_quota_set_info(struct super_block *sb, int type,
{
struct bch_fs *c = sb->s_fs_info;
struct bch_sb_field_quota *sb_quota;
- struct bch_memquota_type *q;
int ret = 0;

if (0) {
@@ -810,8 +809,6 @@ static int bch2_quota_set_info(struct super_block *sb, int type,
~(QC_SPC_TIMER|QC_INO_TIMER|QC_SPC_WARNS|QC_INO_WARNS))
return -EINVAL;

- q = &c->quotas[type];
-
mutex_lock(&c->sb_lock);
sb_quota = bch2_sb_get_or_create_quota(&c->disk_sb);
if (!sb_quota) {
--
2.39.2

2023-09-12 17:20:15

by Brian Foster

[permalink] [raw]
Subject: Re: [PATCH 0/5][next] bcachefs: clean up some redundant assignments

On Tue, Sep 12, 2023 at 01:37:39PM +0100, Colin Ian King wrote:
> Clean up some redundant assignments and variables based on warnings
> found by clang scan build static analysis.
>

These all look good to me. For the series:

Reviewed-by: Brian Foster <[email protected]>

> Colin Ian King (5):
> bcachefs: remove redundant initialization of pointer d
> bcachefs: remove redundant initialization of pointer dst
> bcachefs: remove redundant initializations of variables start_offset
> and end_offset
> bcachefs: remove duplicated assignment to variable offset_into_extent
> bcachefs: remove redundant pointer q
>
> fs/bcachefs/btree_update_interior.c | 2 +-
> fs/bcachefs/buckets.c | 2 +-
> fs/bcachefs/disk_groups.c | 3 +--
> fs/bcachefs/fs-io.c | 4 ++--
> fs/bcachefs/io.c | 1 -
> fs/bcachefs/quota.c | 3 ---
> 6 files changed, 5 insertions(+), 10 deletions(-)
>
> --
> 2.39.2
>

2023-09-12 17:29:57

by Kent Overstreet

[permalink] [raw]
Subject: Re: [PATCH 0/5][next] bcachefs: clean up some redundant assignments

On Tue, Sep 12, 2023 at 01:37:39PM +0100, Colin Ian King wrote:
> Clean up some redundant assignments and variables based on warnings
> found by clang scan build static analysis.
>
> Colin Ian King (5):
> bcachefs: remove redundant initialization of pointer d
> bcachefs: remove redundant initialization of pointer dst
> bcachefs: remove redundant initializations of variables start_offset
> and end_offset
> bcachefs: remove duplicated assignment to variable offset_into_extent
> bcachefs: remove redundant pointer q
>
> fs/bcachefs/btree_update_interior.c | 2 +-
> fs/bcachefs/buckets.c | 2 +-
> fs/bcachefs/disk_groups.c | 3 +--
> fs/bcachefs/fs-io.c | 4 ++--
> fs/bcachefs/io.c | 1 -
> fs/bcachefs/quota.c | 3 ---
> 6 files changed, 5 insertions(+), 10 deletions(-)

Applied - thanks

2023-09-13 11:15:17

by Brian Foster

[permalink] [raw]
Subject: Re: [PATCH 2/5][next] bcachefs: remove redundant initialization of pointer dst

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