On 17.12.18 г. 11:09 ч., Qu Wenruo wrote:
>
>
> 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
Shit, you are right, 0 found, < 0 error, >0 where it must be inserted
>> 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 <nborisov@xxxxxxxx>
> 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];
>> }
>>
>