]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: Consolidate retval checking of core btree functions
authorNikolay Borisov <nborisov@suse.com>
Mon, 17 Dec 2018 09:49:00 +0000 (11:49 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 25 Feb 2019 13:13:22 +0000 (14:13 +0100)
Core btree functions in btrfs generally return 0 when an item is found,
1 in case the sought item cannot be found and <0 when an error happens.
Consolidate the checks for those conditions in one 'if () {} else if ()
{}' construct rather than 2 separate 'if () {}' statements. This
emphasizes that the handling code pertains to a single function. No
functional changes.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c

index 902577d5fc8cd354ad9676442c0d042b62b8d213..c6fc283164b87de58766029b402d5e98214a1bab 100644 (file)
@@ -6795,9 +6795,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]--;
@@ -6847,9 +6845,9 @@ next:
                        if (ret < 0) {
                                err = ret;
                                goto out;
-                       }
-                       if (ret > 0)
+                       } else if (ret > 0) {
                                goto not_found;
+                       }
                        leaf = path->nodes[0];
                }
                btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);