[PATCH 1/1] btrfs: simplify lookup_data_extent()

Anand Jain anand.jain at oracle.com
Wed May 11 04:40:09 CEST 2022


On 5/11/22 01:13, Heinrich Schuchardt wrote:
> After returning if ret <= 0 we know that ret > 0. No need to check it.
> 
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>

Reviewed-by: Anand Jain <anand.jain>


> ---
>   fs/btrfs/inode.c | 15 ++++++---------
>   1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index d00b515333..0173d30cd8 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -546,15 +546,12 @@ static int lookup_data_extent(struct btrfs_root *root, struct btrfs_path *path,
>   	/* Error or we're already at the file extent */
>   	if (ret <= 0)
>   		return ret;
> -	if (ret > 0) {
> -		/* Check previous file extent */
> -		ret = btrfs_previous_item(root, path, ino,
> -					  BTRFS_EXTENT_DATA_KEY);
> -		if (ret < 0)
> -			return ret;
> -		if (ret > 0)
> -			goto check_next;
> -	}
> +	/* Check previous file extent */
> +	ret = btrfs_previous_item(root, path, ino, BTRFS_EXTENT_DATA_KEY);
> +	if (ret < 0)
> +		return ret;
> +	if (ret > 0)
> +		goto check_next;
>   	/* Now the key.offset must be smaller than @file_offset */
>   	btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]);
>   	if (key.objectid != ino ||



More information about the U-Boot mailing list