* [PATCH 0/5][next] bcachefs: clean up some redundant assignments
@ 2023-09-12 12:37 Colin Ian King
2023-09-12 12:37 ` [PATCH 1/5][next] bcachefs: remove redundant initialization of pointer d Colin Ian King
` (6 more replies)
0 siblings, 7 replies; 9+ messages in thread
From: Colin Ian King @ 2023-09-12 12:37 UTC (permalink / raw)
To: Kent Overstreet, Brian Foster, linux-bcachefs
Cc: kernel-janitors, linux-kernel
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/5][next] bcachefs: remove redundant initialization of pointer d
2023-09-12 12:37 [PATCH 0/5][next] bcachefs: clean up some redundant assignments Colin Ian King
@ 2023-09-12 12:37 ` Colin Ian King
2023-09-12 12:37 ` [PATCH 2/5][next] bcachefs: remove redundant initialization of pointer dst Colin Ian King
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Colin Ian King @ 2023-09-12 12:37 UTC (permalink / raw)
To: Kent Overstreet, Brian Foster, linux-bcachefs
Cc: kernel-janitors, linux-kernel
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]
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
fs/bcachefs/btree_update_interior.c | 2 +-
fs/bcachefs/buckets.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c
index 73c950d2788e..35f7af297ac0 100644
--- a/fs/bcachefs/btree_update_interior.c
+++ b/fs/bcachefs/btree_update_interior.c
@@ -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.
diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c
index c02c8c917a29..951f945bbc22 100644
--- a/fs/bcachefs/buckets.c
+++ b/fs/bcachefs/buckets.c
@@ -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;
--
2.39.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/5][next] bcachefs: remove redundant initialization of pointer dst
2023-09-12 12:37 [PATCH 0/5][next] bcachefs: clean up some redundant assignments Colin Ian King
2023-09-12 12:37 ` [PATCH 1/5][next] bcachefs: remove redundant initialization of pointer d Colin Ian King
@ 2023-09-12 12:37 ` Colin Ian King
2023-09-12 13:52 ` Brian Foster
2023-09-12 12:37 ` [PATCH 3/5][next] bcachefs: remove redundant initializations of variables start_offset and end_offset Colin Ian King
` (4 subsequent siblings)
6 siblings, 1 reply; 9+ messages in thread
From: Colin Ian King @ 2023-09-12 12:37 UTC (permalink / raw)
To: Kent Overstreet, Brian Foster, linux-bcachefs
Cc: kernel-janitors, linux-kernel
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
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/5][next] bcachefs: remove redundant initializations of variables start_offset and end_offset
2023-09-12 12:37 [PATCH 0/5][next] bcachefs: clean up some redundant assignments Colin Ian King
2023-09-12 12:37 ` [PATCH 1/5][next] bcachefs: remove redundant initialization of pointer d Colin Ian King
2023-09-12 12:37 ` [PATCH 2/5][next] bcachefs: remove redundant initialization of pointer dst Colin Ian King
@ 2023-09-12 12:37 ` Colin Ian King
2023-09-12 12:37 ` [PATCH 4/5][next] bcachefs: remove duplicated assignment to variable offset_into_extent Colin Ian King
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Colin Ian King @ 2023-09-12 12:37 UTC (permalink / raw)
To: Kent Overstreet, Brian Foster, linux-bcachefs
Cc: kernel-janitors, linux-kernel
The 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]
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
fs/bcachefs/fs-io.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c
index ceab12fb8a8f..c108335e0502 100644
--- a/fs/bcachefs/fs-io.c
+++ b/fs/bcachefs/fs-io.c
@@ -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;
--
2.39.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/5][next] bcachefs: remove duplicated assignment to variable offset_into_extent
2023-09-12 12:37 [PATCH 0/5][next] bcachefs: clean up some redundant assignments Colin Ian King
` (2 preceding siblings ...)
2023-09-12 12:37 ` [PATCH 3/5][next] bcachefs: remove redundant initializations of variables start_offset and end_offset Colin Ian King
@ 2023-09-12 12:37 ` Colin Ian King
2023-09-12 12:37 ` [PATCH 5/5][next] bcachefs: remove redundant pointer q Colin Ian King
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Colin Ian King @ 2023-09-12 12:37 UTC (permalink / raw)
To: Kent Overstreet, Brian Foster, linux-bcachefs
Cc: kernel-janitors, linux-kernel
Variable 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]
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
fs/bcachefs/io.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c
index 3c614c864b6e..3b827c8dbf12 100644
--- a/fs/bcachefs/io.c
+++ b/fs/bcachefs/io.c
@@ -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) {
--
2.39.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 5/5][next] bcachefs: remove redundant pointer q
2023-09-12 12:37 [PATCH 0/5][next] bcachefs: clean up some redundant assignments Colin Ian King
` (3 preceding siblings ...)
2023-09-12 12:37 ` [PATCH 4/5][next] bcachefs: remove duplicated assignment to variable offset_into_extent Colin Ian King
@ 2023-09-12 12:37 ` Colin Ian King
2023-09-12 13:52 ` [PATCH 0/5][next] bcachefs: clean up some redundant assignments Brian Foster
2023-09-12 16:27 ` Kent Overstreet
6 siblings, 0 replies; 9+ messages in thread
From: Colin Ian King @ 2023-09-12 12:37 UTC (permalink / raw)
To: Kent Overstreet, Brian Foster, linux-bcachefs
Cc: kernel-janitors, linux-kernel
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 <colin.i.king@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/5][next] bcachefs: remove redundant initialization of pointer dst
2023-09-12 12:37 ` [PATCH 2/5][next] bcachefs: remove redundant initialization of pointer dst Colin Ian King
@ 2023-09-12 13:52 ` Brian Foster
0 siblings, 0 replies; 9+ messages in thread
From: Brian Foster @ 2023-09-12 13:52 UTC (permalink / raw)
To: Colin Ian King
Cc: Kent Overstreet, linux-bcachefs, kernel-janitors, linux-kernel
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
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/5][next] bcachefs: clean up some redundant assignments
2023-09-12 12:37 [PATCH 0/5][next] bcachefs: clean up some redundant assignments Colin Ian King
` (4 preceding siblings ...)
2023-09-12 12:37 ` [PATCH 5/5][next] bcachefs: remove redundant pointer q Colin Ian King
@ 2023-09-12 13:52 ` Brian Foster
2023-09-12 16:27 ` Kent Overstreet
6 siblings, 0 replies; 9+ messages in thread
From: Brian Foster @ 2023-09-12 13:52 UTC (permalink / raw)
To: Colin Ian King
Cc: Kent Overstreet, linux-bcachefs, kernel-janitors, linux-kernel
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 <bfoster@redhat.com>
> 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
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/5][next] bcachefs: clean up some redundant assignments
2023-09-12 12:37 [PATCH 0/5][next] bcachefs: clean up some redundant assignments Colin Ian King
` (5 preceding siblings ...)
2023-09-12 13:52 ` [PATCH 0/5][next] bcachefs: clean up some redundant assignments Brian Foster
@ 2023-09-12 16:27 ` Kent Overstreet
6 siblings, 0 replies; 9+ messages in thread
From: Kent Overstreet @ 2023-09-12 16:27 UTC (permalink / raw)
To: Colin Ian King
Cc: Brian Foster, linux-bcachefs, kernel-janitors, linux-kernel
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
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-09-12 16:28 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-12 12:37 [PATCH 0/5][next] bcachefs: clean up some redundant assignments Colin Ian King
2023-09-12 12:37 ` [PATCH 1/5][next] bcachefs: remove redundant initialization of pointer d Colin Ian King
2023-09-12 12:37 ` [PATCH 2/5][next] bcachefs: remove redundant initialization of pointer dst Colin Ian King
2023-09-12 13:52 ` Brian Foster
2023-09-12 12:37 ` [PATCH 3/5][next] bcachefs: remove redundant initializations of variables start_offset and end_offset Colin Ian King
2023-09-12 12:37 ` [PATCH 4/5][next] bcachefs: remove duplicated assignment to variable offset_into_extent Colin Ian King
2023-09-12 12:37 ` [PATCH 5/5][next] bcachefs: remove redundant pointer q Colin Ian King
2023-09-12 13:52 ` [PATCH 0/5][next] bcachefs: clean up some redundant assignments Brian Foster
2023-09-12 16:27 ` Kent Overstreet
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).