[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAKXUXMyjh1mnLpyu_xa4vWAv9Bn_EN3YdhQ_r1aD58YvFTRORA@mail.gmail.com>
Date: Sun, 16 May 2021 10:53:57 +0200
From: Lukas Bulwahn <lukas.bulwahn@...il.com>
To: Yang Li <yang.lee@...ux.alibaba.com>
Cc: clm@...com, Josef Bacik <josef@...icpanda.com>,
David Sterba <dsterba@...e.com>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
linux-btrfs@...r.kernel.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
clang-built-linux <clang-built-linux@...glegroups.com>
Subject: Re: [PATCH] btrfs: Remove redundant initialization of 'to_add'
On Fri, May 14, 2021 at 11:24 AM Yang Li <yang.lee@...ux.alibaba.com> wrote:
>
> Variable 'to_add' is being initialized however this value is never
> read as 'to_add' is assigned a new value in if statement. Remove the
> redundant assignment. At the same time, move its declaration into the
> if statement, because the variable is not used elsewhere.
>
> Clean up clang warning:
>
> fs/btrfs/extent-tree.c:2773:8: warning: Value stored to 'to_add' during
> its initialization is never read [clang-analyzer-deadcode.DeadStores]
>
> Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
> Signed-off-by: Yang Li <yang.lee@...ux.alibaba.com>
> ---
> fs/btrfs/extent-tree.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index f1d15b6..e7b2289 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -2774,10 +2774,10 @@ static int unpin_extent_range(struct btrfs_fs_info *fs_info,
> spin_unlock(&cache->lock);
> if (!readonly && return_free_space &&
> global_rsv->space_info == space_info) {
> - u64 to_add = len;
>
> spin_lock(&global_rsv->lock);
> if (!global_rsv->full) {
> + u64 to_add;
> to_add = min(len, global_rsv->size -
> global_rsv->reserved);
Yang Li, you could just combine these two lines above, right?
So:
u64 to_add = min(len, ...);
By the way, great contribution on addressing all those dead stores
identified by clang analyzer... I wish I would also have more time on
addressing some of those remaining...
Lukas
Powered by blists - more mailing lists