[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250905171313.GO5333@twin.jikos.cz>
Date: Fri, 5 Sep 2025 19:13:13 +0200
From: David Sterba <dsterba@...e.cz>
To: Xichao Zhao <zhao.xichao@...o.com>
Cc: clm@...com, josef@...icpanda.com, dsterba@...e.com,
linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] btrfs: remove redundant condition checks
On Fri, Sep 05, 2025 at 04:01:03PM +0800, Xichao Zhao wrote:
> Remove redundant condition checks and replace else if with else.
>
> Signed-off-by: Xichao Zhao <zhao.xichao@...o.com>
> ---
> fs/btrfs/inode-item.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/inode-item.c b/fs/btrfs/inode-item.c
> index f06cf701ae5a..3d0631bf7389 100644
> --- a/fs/btrfs/inode-item.c
> +++ b/fs/btrfs/inode-item.c
> @@ -531,7 +531,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
> if (extent_type != BTRFS_FILE_EXTENT_INLINE)
> item_end +=
> btrfs_file_extent_num_bytes(leaf, fi);
> - else if (extent_type == BTRFS_FILE_EXTENT_INLINE)
> + else
I'd rather explicitly check for the values and add a separate fallback
statement that will catch unexpected values and propagates the errors.
As you did it we'd assume that everything "else" has to be
BTRFS_FILE_EXTENT_INLINE which may not be true in case of error.
> item_end += btrfs_file_extent_ram_bytes(leaf, fi);
>
> btrfs_trace_truncate(control->inode, leaf, fi,
Powered by blists - more mailing lists