fs/btrfs/inode-item.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Remove redundant condition checks and replace else if with else.
Signed-off-by: Xichao Zhao <zhao.xichao@vivo.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
item_end += btrfs_file_extent_ram_bytes(leaf, fi);
btrfs_trace_truncate(control->inode, leaf, fi,
@@ -586,7 +586,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
control->sub_bytes += num_dec;
}
clear_len = num_dec;
- } else if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
+ } else {
/*
* We can't truncate inline items that have had
* special encodings
--
2.34.1
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@vivo.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,
© 2016 - 2025 Red Hat, Inc.