[PATCH] btrfs: fixed an incorrect variable assignment

liujing posted 1 patch 3 years, 6 months ago
fs/btrfs/block-group.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] btrfs: fixed an incorrect variable assignment
Posted by liujing 3 years, 6 months ago
In the btrfs_reclaim_bgs_work function, 
there is an assignment of int ret =0, 
but this assignment is not used in the following code, 
so it can be defined as int ret.

Signed-off-by: liujing <liujing@cmss.chinamobile.com>
---
 fs/btrfs/block-group.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index c52b6e245b9a..a4c7fb423244 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -1571,7 +1571,7 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
 	list_sort(NULL, &fs_info->reclaim_bgs, reclaim_bgs_cmp);
 	while (!list_empty(&fs_info->reclaim_bgs)) {
 		u64 zone_unusable;
-		int ret = 0;
+		int ret;
 
 		bg = list_first_entry(&fs_info->reclaim_bgs,
 				      struct btrfs_block_group,
-- 
2.18.2
Re: [PATCH] btrfs: fixed an incorrect variable assignment
Posted by David Sterba 3 years, 5 months ago
On Thu, Sep 15, 2022 at 11:11:49PM -0400, liujing wrote:
> In the btrfs_reclaim_bgs_work function, 
> there is an assignment of int ret =0, 
> but this assignment is not used in the following code, 
> so it can be defined as int ret.
> 
> Signed-off-by: liujing <liujing@cmss.chinamobile.com>
> ---
>  fs/btrfs/block-group.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> index c52b6e245b9a..a4c7fb423244 100644
> --- a/fs/btrfs/block-group.c
> +++ b/fs/btrfs/block-group.c
> @@ -1571,7 +1571,7 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
>  	list_sort(NULL, &fs_info->reclaim_bgs, reclaim_bgs_cmp);
>  	while (!list_empty(&fs_info->reclaim_bgs)) {
>  		u64 zone_unusable;
> -		int ret = 0;
> +		int ret;

I'm not sure we need to fix that, is it fixing some warning? Also please
rephrase the subject, it's not 'incorrect', the code works as expected
but the initial value is not used.