bcachefs: clean up some redundant assignments
cover 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(-)
Signature · 1 line
2.39.2
PATCH 1/5 bcachefs: remove redundant initialization of pointer d
The pointer d is being initialized with a value that is never read, it is being re-assigned later on when it is used in a for-loop. The initialization is redundant and can be removed.
Cleans up clang-scan build warning:fs/bcachefs/buckets.c:1303:25: warning: Value stored to 'd' during its initialization is never read [deadcode.DeadStores]
--- fs/bcachefs/btree_update_interior.c | 2 +- fs/bcachefs/buckets.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/bcachefs/btree_update_interior.c +1 -1
@@ -143,7 +143,7 @@ static size_t btree_node_u64s_with_format(struct btree *b, }/** -* btree_node_format_fits - check if we could rewrite node with a new format +* bch2_btree_node_format_fits - check if we could rewrite node with a new format * * This assumes all keys can pack with the new format -- it just checks if * the re-packed keys would fit inside the node itself.
fs/bcachefs/buckets.c +1 -1
@@ -1300,7 +1300,7 @@ int bch2_trans_fs_usage_apply(struct btree_trans *trans,static int warned_disk_usage =0 ;bool warn = false;unsigned disk_res_sectors = trans->disk_res ? trans->disk_res->sectors :0 ; -struct replicas_delta *d = deltas->d, *d2; +struct replicas_delta *d, *d2;struct replicas_delta *top = (void *) deltas->d + deltas->used;struct bch_fs_usage *dst;s64 added =0 , should_not_have_added;
Signature · 1 line
2.39.2
PATCH 2/5 bcachefs: remove redundant initialization of pointer dst
In reply to Colin Ian KingThe 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]
--- fs/bcachefs/disk_groups.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/bcachefs/disk_groups.c +1 -2
@@ -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 ;
Signature · 1 line
2.39.2
PATCH 3/5 bcachefs: remove redundant initializations of variables start_offset and end_offset
In reply to Colin Ian KingThe variables start_offset and end_offset are being initialized with values that are never read, they being re-assigned later on. The initializations are redundant and can be removed.
Cleans up clang-scan build warnings:fs/bcachefs/fs-io.c:243:11: warning: Value stored to 'start_offset' during its initialization is never read [deadcode.DeadStores] fs/bcachefs/fs-io.c:244:11: warning: Value stored to 'end_offset' during its initialization is never read [deadcode.DeadStores]
--- fs/bcachefs/fs-io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/bcachefs/fs-io.c +2 -2
@@ -240,8 +240,8 @@ static int __bch2_truncate_folio(struct bch_inode_info *inode,struct bch_fs *c = inode->v.i_sb->s_fs_info;struct address_space *mapping = inode->v.i_mapping;struct bch_folio *s; -unsigned start_offset = start & (PAGE_SIZE -1 ); -unsigned end_offset = ((end -1 ) & (PAGE_SIZE -1 )) +1 ; +unsigned start_offset; +unsigned end_offset;unsigned i;struct folio *folio;s64 i_sectors_delta =0 ;
Signature · 1 line
2.39.2
PATCH 4/5 bcachefs: remove duplicated assignment to variable offset_into_extent
In reply to Colin Ian KingVariable offset_into_extent is being assigned to zero and a few statements later it is being re-assigned again to the save value. The second assignment is redundant and can be removed. Cleans up clang-scan build warning:
fs/bcachefs/io.c:2722:3: warning: Value stored to 'offset_into_extent' is never read [deadcode.DeadStores]
--- fs/bcachefs/io.c | 1 - 1 file changed, 1 deletion(-)
fs/bcachefs/io.c +0 -1
@@ -2724,7 +2724,6 @@ int __bch2_read_extent(struct btree_trans *trans, struct bch_read_bio *orig, pick.crc.uncompressed_size =bvec_iter_sectors (iter); pick.crc.offset =0 ; pick.crc.live_size =bvec_iter_sectors (iter); - offset_into_extent =0 ; } get_bio:if (rbio) {
Signature · 1 line
2.39.2
PATCH 5/5 bcachefs: remove redundant pointer q
In reply to Colin Ian KingThe 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]
--- fs/bcachefs/quota.c | 3 --- 1 file changed, 3 deletions(-)
fs/bcachefs/quota.c +0 -3
@@ -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) {
Signature · 1 line
2.39.2
Re: [PATCH 2/5][next] bcachefs: remove redundant initialization of pointer dst
In reply to Colin Ian KingQuoted 18 lines · Colin Ian King
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(-)fs/bcachefs/disk_groups.c +0
-0
fs/bcachefs/disk_groups.c int bch2_sb_disk_groups_to_cpu(struct bch_fs *c) · line 186
Quoted 6 lines
fs/bcachefs/disk_groups.c +1
-2@@ -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
Quoted 6 lines
fs/bcachefs/disk_groups.c +0
-0if (!bch2_member_exists (m))continue ;Signature · 1 line
2.39.2
Quoted 3 lines · Colin Ian King
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:
Quoted 19 lines
Colin Ian King (5):
bcachefs: remove redundant initialization of pointer d
bcachefs: remove redundant initialization of pointer dst
bcachefs: remove redundant initializations of variablesstart_offset
andend_offset
bcachefs: remove duplicated assignment to variableoffset_into_extent
bcachefs: remove redundant pointer qfs/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(-)Signature · 1 line
2.39.2
Quoted 11 lines · Colin Ian King
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 variablesstart_offset
andend_offset
bcachefs: remove duplicated assignment to variableoffset_into_extent
bcachefs: remove redundant pointer q
Quoted 7 lines
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