public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: Anand Jain <anand.jain@oracle.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 24/29] btrfs: btrfs_drop_snapshot rename ret to ret2 and err to ret
Date: Tue, 19 Mar 2024 14:20:12 -0400	[thread overview]
Message-ID: <20240319182012.GK2982591@perftesting> (raw)
In-Reply-To: <d7c6a92fa4199b7b0e95eb02ac5d10689d7222d7.1710857863.git.anand.jain@oracle.com>

On Tue, Mar 19, 2024 at 08:25:32PM +0530, Anand Jain wrote:
> To fix code style for the return variable, first rename ret to ret2
> comopile and then rename err to ret.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  fs/btrfs/extent-tree.c | 82 +++++++++++++++++++++---------------------
>  1 file changed, 41 insertions(+), 41 deletions(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 4b0a55e66a55..acea2a7be4e5 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -5858,8 +5858,8 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
>  	struct btrfs_root_item *root_item = &root->root_item;
>  	struct walk_control *wc;
>  	struct btrfs_key key;
> -	int err = 0;
> -	int ret;
> +	int ret = 0;
> +	int ret2;
>  	int level;
>  	bool root_dropped = false;
>  	bool unfinished_drop = false;
> @@ -5868,14 +5868,14 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
>  
>  	path = btrfs_alloc_path();
>  	if (!path) {
> -		err = -ENOMEM;
> +		ret = -ENOMEM;
>  		goto out;
>  	}
>  
>  	wc = kzalloc(sizeof(*wc), GFP_NOFS);
>  	if (!wc) {
>  		btrfs_free_path(path);
> -		err = -ENOMEM;
> +		ret = -ENOMEM;
>  		goto out;
>  	}
>  
> @@ -5888,12 +5888,12 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
>  	else
>  		trans = btrfs_start_transaction(tree_root, 0);
>  	if (IS_ERR(trans)) {
> -		err = PTR_ERR(trans);
> +		ret = PTR_ERR(trans);
>  		goto out_free;
>  	}
>  
> -	err = btrfs_run_delayed_items(trans);
> -	if (err)
> +	ret = btrfs_run_delayed_items(trans);
> +	if (ret)
>  		goto out_end_trans;
>  
>  	/*
> @@ -5922,13 +5922,13 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
>  		level = btrfs_root_drop_level(root_item);
>  		BUG_ON(level == 0);
>  		path->lowest_level = level;
> -		ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
> +		ret2 = btrfs_search_slot(NULL, root, &key, path, 0, 0);
>  		path->lowest_level = 0;
> -		if (ret < 0) {
> -			err = ret;
> +		if (ret2 < 0) {
> +			ret = ret2;
>  			goto out_end_trans;
>  		}
> -		WARN_ON(ret > 0);
> +		WARN_ON(ret2 > 0);
>  
>  		/*
>  		 * unlock our path, this is safe because only this
> @@ -5941,12 +5941,12 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
>  			btrfs_tree_lock(path->nodes[level]);
>  			path->locks[level] = BTRFS_WRITE_LOCK;
>  
> -			ret = btrfs_lookup_extent_info(trans, fs_info,
> +			ret2 = btrfs_lookup_extent_info(trans, fs_info,
>  						path->nodes[level]->start,
>  						level, 1, &wc->refs[level],
>  						&wc->flags[level], NULL);
> -			if (ret < 0) {
> -				err = ret;
> +			if (ret2 < 0) {
> +				ret = ret2;
>  				goto out_end_trans;
>  			}
>  			BUG_ON(wc->refs[level] == 0);
> @@ -5971,21 +5971,21 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
>  
>  	while (1) {
>  
> -		ret = walk_down_tree(trans, root, path, wc);
> -		if (ret < 0) {
> -			btrfs_abort_transaction(trans, ret);
> -			err = ret;
> +		ret2 = walk_down_tree(trans, root, path, wc);
> +		if (ret2 < 0) {
> +			btrfs_abort_transaction(trans, ret2);
> +			ret = ret2;
>  			break;
>  		}
>  
> -		ret = walk_up_tree(trans, root, path, wc, BTRFS_MAX_LEVEL);
> -		if (ret < 0) {
> -			btrfs_abort_transaction(trans, ret);
> -			err = ret;
> +		ret2 = walk_up_tree(trans, root, path, wc, BTRFS_MAX_LEVEL);
> +		if (ret2 < 0) {
> +			btrfs_abort_transaction(trans, ret2);
> +			ret = ret2;
>  			break;
>  		}
>  
> -		if (ret > 0) {
> +		if (ret2 > 0) {
>  			BUG_ON(wc->stage != DROP_REFERENCE);

This can be changed to

if (ret > 0) {
	BUG_ON(wc->stage != DROP_REFERENCE);
	ret = 0;
	break;
}

>  			break;
>  		}
> @@ -6003,12 +6003,12 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
>  		BUG_ON(wc->level == 0);
>  		if (btrfs_should_end_transaction(trans) ||
>  		    (!for_reloc && btrfs_need_cleaner_sleep(fs_info))) {
> -			ret = btrfs_update_root(trans, tree_root,
> +			ret2 = btrfs_update_root(trans, tree_root,
>  						&root->root_key,
>  						root_item);
> -			if (ret) {
> -				btrfs_abort_transaction(trans, ret);
> -				err = ret;
> +			if (ret2) {
> +				btrfs_abort_transaction(trans, ret2);
> +				ret = ret2;
>  				goto out_end_trans;
>  			}
>  
> @@ -6019,7 +6019,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
>  			if (!for_reloc && btrfs_need_cleaner_sleep(fs_info)) {
>  				btrfs_debug(fs_info,
>  					    "drop snapshot early exit");
> -				err = -EAGAIN;
> +				ret = -EAGAIN;
>  				goto out_free;
>  			}
>  
> @@ -6033,30 +6033,30 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
>  			else
>  				trans = btrfs_start_transaction(tree_root, 0);
>  			if (IS_ERR(trans)) {
> -				err = PTR_ERR(trans);
> +				ret = PTR_ERR(trans);
>  				goto out_free;
>  			}
>  		}
>  	}
>  	btrfs_release_path(path);
> -	if (err)
> +	if (ret)
>  		goto out_end_trans;
>  
> -	ret = btrfs_del_root(trans, &root->root_key);
> -	if (ret) {
> -		btrfs_abort_transaction(trans, ret);
> -		err = ret;
> +	ret2 = btrfs_del_root(trans, &root->root_key);
> +	if (ret2) {
> +		btrfs_abort_transaction(trans, ret2);
> +		ret = ret2;
>  		goto out_end_trans;
>  	}
>  
>  	if (!is_reloc_root) {
> -		ret = btrfs_find_root(tree_root, &root->root_key, path,
> +		ret2 = btrfs_find_root(tree_root, &root->root_key, path,
>  				      NULL, NULL);
> -		if (ret < 0) {
> -			btrfs_abort_transaction(trans, ret);
> -			err = ret;
> +		if (ret2 < 0) {
> +			btrfs_abort_transaction(trans, ret2);
> +			ret = ret2;
>  			goto out_end_trans;
> -		} else if (ret > 0) {
> +		} else if (ret2 > 0) {

And then here we just set ret = 0 again, and then we have no need for ret2.
Thanks,

Josef

  reply	other threads:[~2024-03-19 18:20 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-19 14:55 [PATCH 00/29] trivial adjustments for return variable coding style Anand Jain
2024-03-19 14:55 ` [PATCH 01/29] btrfs: btrfs_cleanup_fs_roots rename ret to ret2 and err to ret Anand Jain
2024-03-19 17:38   ` Josef Bacik
2024-03-19 20:43   ` Qu Wenruo
2024-04-17  3:24     ` Anand Jain
2024-04-17  3:59       ` Qu Wenruo
2024-03-20 21:17   ` Goffredo Baroncelli
2024-03-19 14:55 ` [PATCH 02/29] btrfs: btrfs_initxattrs rename " Anand Jain
2024-03-19 14:55 ` [PATCH 03/29] btrfs: send_extent_data " Anand Jain
2024-03-20 12:59   ` Filipe Manana
2024-03-19 14:55 ` [PATCH 04/29] btrfs: btrfs_rmdir " Anand Jain
2024-03-19 14:55 ` [PATCH 05/29] btrfs: btrfs_cont_expand " Anand Jain
2024-03-19 14:55 ` [PATCH 06/29] btrfs: btrfs_setsize rename err to ret2 Anand Jain
2024-03-19 14:55 ` [PATCH 07/29] btrfs: btrfs_find_orphan_roots rename ret to ret2 and err to ret Anand Jain
2024-03-19 17:44   ` Josef Bacik
2024-03-19 21:09   ` Qu Wenruo
2024-03-19 14:55 ` [PATCH 08/29] btrfs: btrfs_ioctl_snap_destroy rename " Anand Jain
2024-03-19 14:55 ` [PATCH 09/29] btrfs: __set_extent_bit " Anand Jain
2024-03-19 14:55 ` [PATCH 10/29] btrfs: convert_extent_bit " Anand Jain
2024-03-19 14:55 ` [PATCH 11/29] btrfs: __btrfs_end_transaction " Anand Jain
2024-03-19 14:55 ` [PATCH 12/29] btrfs: btrfs_write_marked_extents rename werr to ret err to ret2 Anand Jain
2024-03-19 17:53   ` Josef Bacik
2024-04-16  2:39     ` Anand Jain
2024-03-19 21:25   ` Qu Wenruo
2024-04-16  3:18     ` Anand Jain
2024-03-19 14:55 ` [PATCH 13/29] btrfs: __btrfs_wait_marked_extents " Anand Jain
2024-03-19 17:54   ` Josef Bacik
2024-03-19 23:47   ` Qu Wenruo
2024-03-19 14:55 ` [PATCH 14/29] btrfs: build_backref_tree rename err to ret and ret " Anand Jain
2024-03-19 17:57   ` Josef Bacik
2024-03-19 14:55 ` [PATCH 15/29] btrfs: relocate_tree_blocks rename ret to ret2 and err to ret Anand Jain
2024-03-19 17:58   ` Josef Bacik
2024-03-19 14:55 ` [PATCH 16/29] btrfs: relocate_block_group " Anand Jain
2024-03-19 14:55 ` [PATCH 17/29] btrfs: create_reloc_inode rename " Anand Jain
2024-03-19 14:55 ` [PATCH 18/29] btrfs: btrfs_relocate_block_group rename ret to ret2 and err ro ret Anand Jain
2024-03-19 18:04   ` Josef Bacik
2024-03-19 14:55 ` [PATCH 19/29] btrfs: mark_garbage_root rename err to ret2 Anand Jain
2024-03-19 18:07   ` Josef Bacik
2024-03-22  2:29     ` David Sterba
2024-03-19 14:55 ` [PATCH 20/29] btrfs: btrfs_recover_relocation rename ret to ret2 and err to ret Anand Jain
2024-03-19 14:55 ` [PATCH 21/29] btrfs: quick_update_accounting rename err to ret2 Anand Jain
2024-03-19 18:10   ` Josef Bacik
2024-03-19 14:55 ` [PATCH 22/29] btrfs: btrfs_qgroup_rescan_worker rename ret to ret2 and err to ret Anand Jain
2024-03-19 14:55 ` [PATCH 23/29] btrfs: lookup_extent_data_ref " Anand Jain
2024-03-19 18:17   ` Josef Bacik
2024-04-18  6:55     ` Anand Jain
2024-03-19 14:55 ` [PATCH 24/29] btrfs: btrfs_drop_snapshot " Anand Jain
2024-03-19 18:20   ` Josef Bacik [this message]
2024-03-19 14:55 ` [PATCH 25/29] btrfs: btrfs_drop_subtree rename retw to ret2 Anand Jain
2024-03-19 18:22   ` Josef Bacik
2024-03-19 14:55 ` [PATCH 26/29] btrfs: btrfs_dirty_pages rename variable err to ret Anand Jain
2024-03-19 14:55 ` [PATCH 27/29] btrfs: prepare_pages rename " Anand Jain
2024-03-19 14:55 ` [PATCH 28/29] btrfs: btrfs_direct_write " Anand Jain
2024-03-19 14:55 ` [PATCH 29/29] btrfs: fixup_tree_root_location rename ret to ret2 and " Anand Jain
2024-03-19 18:24   ` Josef Bacik
2024-04-16 10:42     ` Anand Jain
2024-04-16 10:44       ` Anand Jain
2024-03-22  2:32 ` [PATCH 00/29] trivial adjustments for return variable coding style David Sterba
2024-03-25  9:37   ` Anand Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240319182012.GK2982591@perftesting \
    --to=josef@toxicpanda.com \
    --cc=anand.jain@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox