[PATCH v2 2/4] btrfs: Consolidate retval checking of core btree functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 () {}' 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>
---

V2: 
 * Properly describe return value convention in changelog no other changes. 

 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];
 		}
-- 
2.17.1




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux