Re: [PATCH 25/29] btrfs: btrfs_drop_subtree rename retw to ret2

Josef Bacik
2024-03-19T18:22:17Z

On Tue, Mar 19, 2024 at 08:25:33PM +0530, Anand Jain wrote:
> retw is a helper return variable used to update the actual return value
> ret. Rename it to ret2.
>
> Additionally, ret2 is used only inside 'while (1)', which could potentially
> be declared inside the loop. I chose not to do that to minimize the number
> of times the 'while' loop has to allocate/deallocate.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> fs/btrfs/extent-tree.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index acea2a7be4e5..5064cdd55d2f 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -6125,7 +6125,7 @@ int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
> int level;
> int parent_level;
> int ret = 0;
> - int wret;
> + int ret2;
>
> BUG_ON(root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID);
>
> @@ -6161,16 +6161,16 @@ int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
> wc->reada_count = BTRFS_NODEPTRS_PER_BLOCK(fs_info);
>
> while (1) {
> - wret = walk_down_tree(trans, root, path, wc);
> - if (wret < 0) {
> - ret = wret;
> + ret2 = walk_down_tree(trans, root, path, wc);
> + if (ret2 < 0) {
> + ret = ret2;
> break;
> }
>
> - wret = walk_up_tree(trans, root, path, wc, parent_level);
> - if (wret < 0)
> - ret = wret;
> - if (wret != 0)
> + ret2 = walk_up_tree(trans, root, path, wc, parent_level);
> + if (ret2 < 0)
> + ret = ret2;
> + if (ret2 != 0)

This can be reworked to

ret = walk_up_tree();
if (ret) {
if (ret > 0)
ret = 0;
break;
}

and then we don't need ret2. Thanks,

Josef