* [PATCH v2] btrfs: Remove redundant assignment of slot and leaf
@ 2022-01-05 15:07 Jiapeng Chong
2022-01-05 16:11 ` Filipe Manana
0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2022-01-05 15:07 UTC (permalink / raw)
To: clm; +Cc: josef, dsterba, linux-btrfs, linux-kernel, chongjiapeng,
Abaci Robot
From: chongjiapeng <jiapeng.chong@linux.alibaba.com>
slot and leaf are being initialized to path->slots[0] and
path->nodes[0], but this is never read as slot and leaf
is overwritten later on. Remove the redundant assignment.
Cleans up the following clang-analyzer warning:
fs/btrfs/tree-log.c:6125:7: warning: Value stored to 'slot' during its
initialization is never read [clang-analyzer-deadcode.DeadStores].
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: chongjiapeng <jiapeng.chong@linux.alibaba.com>
---
Changes in v2:
-Remove redundant assignment of leaf.
fs/btrfs/tree-log.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 4b89ac769347..d99cda0acd95 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -6188,8 +6188,6 @@ static int log_new_ancestors(struct btrfs_trans_handle *trans,
if (ret < 0)
return ret;
- leaf = path->nodes[0];
- slot = path->slots[0];
if (slot >= btrfs_header_nritems(leaf)) {
ret = btrfs_next_leaf(root, path);
if (ret < 0)
--
2.19.1.6.gb485710b
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] btrfs: Remove redundant assignment of slot and leaf
2022-01-05 15:07 [PATCH v2] btrfs: Remove redundant assignment of slot and leaf Jiapeng Chong
@ 2022-01-05 16:11 ` Filipe Manana
0 siblings, 0 replies; 2+ messages in thread
From: Filipe Manana @ 2022-01-05 16:11 UTC (permalink / raw)
To: Jiapeng Chong; +Cc: clm, josef, dsterba, linux-btrfs, linux-kernel, Abaci Robot
On Wed, Jan 05, 2022 at 11:07:58PM +0800, Jiapeng Chong wrote:
> From: chongjiapeng <jiapeng.chong@linux.alibaba.com>
>
> slot and leaf are being initialized to path->slots[0] and
> path->nodes[0], but this is never read as slot and leaf
> is overwritten later on. Remove the redundant assignment.
>
> Cleans up the following clang-analyzer warning:
>
> fs/btrfs/tree-log.c:6125:7: warning: Value stored to 'slot' during its
> initialization is never read [clang-analyzer-deadcode.DeadStores].
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: chongjiapeng <jiapeng.chong@linux.alibaba.com>
> ---
> Changes in v2:
> -Remove redundant assignment of leaf.
>
> fs/btrfs/tree-log.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
> index 4b89ac769347..d99cda0acd95 100644
> --- a/fs/btrfs/tree-log.c
> +++ b/fs/btrfs/tree-log.c
> @@ -6188,8 +6188,6 @@ static int log_new_ancestors(struct btrfs_trans_handle *trans,
> if (ret < 0)
> return ret;
>
> - leaf = path->nodes[0];
> - slot = path->slots[0];
No, this is not correct.
Right before those assignments we called btrfs_search_slot(), which updates
path->nodes and path->slots, and we need those updated values below.
The redundant assignments are not these two, but instead the ones when the
variables are declared at the top of the loop:
struct extent_buffer *leaf = path->nodes[0];
int slot = path->slots[0];
Thanks.
> if (slot >= btrfs_header_nritems(leaf)) {
> ret = btrfs_next_leaf(root, path);
> if (ret < 0)
> --
> 2.19.1.6.gb485710b
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-05 16:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-05 15:07 [PATCH v2] btrfs: Remove redundant assignment of slot and leaf Jiapeng Chong
2022-01-05 16:11 ` Filipe Manana
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox