On 2018/12/17 下午4:36, Nikolay Borisov wrote:
> Core btree functions in btrfs generally return 0 for error
Isn't 0 for key found? It's <0 for error.
and 1 in case
> the sought item cannot be found. Consolidate the checks for those
> conditions in one 'if () {} else if () {}' struct rather than 2 separate
> 'if () {}' statements. This emphasizes that the handling code pertains
> to a single function. No functional changes.
>
> Signed-off-by: Nikolay Borisov <[email protected]>
The code itself is OK, but the commit message is really confusing.
Thanks,
Qu
> ---
> fs/btrfs/inode.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index fe25f66a98d9..511d3b314af2 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -6801,9 +6801,7 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode
> *inode,
> if (ret < 0) {
> err = ret;
> goto out;
> - }
> -
> - if (ret != 0) {
> + } else if (ret > 0) {
> if (path->slots[0] == 0)
> goto not_found;
> path->slots[0]--;
> @@ -6853,8 +6851,7 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode
> *inode,
> if (ret < 0) {
> err = ret;
> goto out;
> - }
> - if (ret > 0)
> + } else if (ret > 0)
> goto not_found;
> leaf = path->nodes[0];
> }
>
- [PATCH 0/4] Misc cleanups of btrfs_get_extent Nikolay Borisov
- [PATCH 3/4] btrfs: Refactor retval handling of btr... Nikolay Borisov
- Re: [PATCH 3/4] btrfs: Refactor retval handlin... Johannes Thumshirn
- Re: [PATCH 3/4] btrfs: Refactor retval handlin... David Sterba
- [PATCH 1/4] btrfs: Rename found_type to extent_typ... Nikolay Borisov
- Re: [PATCH 1/4] btrfs: Rename found_type to ex... Johannes Thumshirn
- Re: [PATCH 1/4] btrfs: Rename found_type to ex... Qu Wenruo
- [PATCH 2/4] btrfs: Consolidate retval checking of ... Nikolay Borisov
- Re: [PATCH 2/4] btrfs: Consolidate retval chec... Johannes Thumshirn
- Re: [PATCH 2/4] btrfs: Consolidate retval ... Nikolay Borisov
- Re: [PATCH 2/4] btrfs: Consolidate retval chec... Qu Wenruo
- Re: [PATCH 2/4] btrfs: Consolidate retval ... Nikolay Borisov
- [PATCH v2 2/4] btrfs: Consolidate retval check... Nikolay Borisov
- [PATCH 4/4] btrfs: Remove not_found_em label from ... Nikolay Borisov
- Re: [PATCH 4/4] btrfs: Remove not_found_em lab... Johannes Thumshirn
- Re: [PATCH 0/4] Misc cleanups of btrfs_get_extent David Sterba
