linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] btrfs: zoned: Remove redundant initialization of to_add
@ 2022-01-21 11:43 Jiapeng Chong
  2022-01-21 11:48 ` Nikolay Borisov
  2022-01-24 19:41 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Jiapeng Chong @ 2022-01-21 11:43 UTC (permalink / raw)
  To: clm; +Cc: josef, dsterba, linux-btrfs, linux-kernel, Jiapeng Chong, Abaci Robot

to_add is being initialized to len but this is never read as
to_add is overwritten later on. Remove the redundant
initialization.

Cleans up the following clang-analyzer warning:

fs/btrfs/extent-tree.c:2769:8: warning: Value stored to 'to_add' during
its initialization is never read [clang-analyzer-deadcode.DeadStores].

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
Changes in v2:
  -"to_add" is define within the if (!global_rsv->full) branch.

 fs/btrfs/extent-tree.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index d89273c4b6b8..8e91adbf352e 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2766,12 +2766,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) {
-				to_add = min(len, global_rsv->size -
-					     global_rsv->reserved);
+				u64 to_add = min(len, global_rsv->size -
+						 global_rsv->reserved);
 				global_rsv->reserved += to_add;
 				btrfs_space_info_update_bytes_may_use(fs_info,
 						space_info, to_add);
-- 
2.20.1.7.g153144c


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] btrfs: zoned: Remove redundant initialization of to_add
  2022-01-21 11:43 [PATCH v2] btrfs: zoned: Remove redundant initialization of to_add Jiapeng Chong
@ 2022-01-21 11:48 ` Nikolay Borisov
  2022-01-24 19:41 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Nikolay Borisov @ 2022-01-21 11:48 UTC (permalink / raw)
  To: Jiapeng Chong, clm; +Cc: josef, dsterba, linux-btrfs, linux-kernel, Abaci Robot



On 21.01.22 г. 13:43, Jiapeng Chong wrote:
> to_add is being initialized to len but this is never read as
> to_add is overwritten later on. Remove the redundant
> initialization.
> 
> Cleans up the following clang-analyzer warning:
> 
> fs/btrfs/extent-tree.c:2769:8: warning: Value stored to 'to_add' during
> its initialization is never read [clang-analyzer-deadcode.DeadStores].
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] btrfs: zoned: Remove redundant initialization of to_add
  2022-01-21 11:43 [PATCH v2] btrfs: zoned: Remove redundant initialization of to_add Jiapeng Chong
  2022-01-21 11:48 ` Nikolay Borisov
@ 2022-01-24 19:41 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2022-01-24 19:41 UTC (permalink / raw)
  To: Jiapeng Chong; +Cc: clm, josef, dsterba, linux-btrfs, linux-kernel, Abaci Robot

On Fri, Jan 21, 2022 at 07:43:51PM +0800, Jiapeng Chong wrote:
> to_add is being initialized to len but this is never read as
> to_add is overwritten later on. Remove the redundant
> initialization.
> 
> Cleans up the following clang-analyzer warning:
> 
> fs/btrfs/extent-tree.c:2769:8: warning: Value stored to 'to_add' during
> its initialization is never read [clang-analyzer-deadcode.DeadStores].
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>

Added to misc-next, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-24 19:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-21 11:43 [PATCH v2] btrfs: zoned: Remove redundant initialization of to_add Jiapeng Chong
2022-01-21 11:48 ` Nikolay Borisov
2022-01-24 19:41 ` David Sterba

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).