summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-10-23 12:18:03 -0400
committerChris Mason <chris.mason@fusionio.com>2013-10-24 05:57:44 -0400
commitb91d84abc0df2195aaa06a79b565d8852b3099b2 (patch)
treeb6868496f083c512c9836cdc51a5fb58aaf59d3e
parentcee267d8c8175e6f8cd7605ccb11379a20ea8c99 (diff)
Btrfs-progs: just return -ENOENT if we don't find the root item
We were bug_on(slot == 0), but that's just obnoxious, return -ENOENT so we can handle the situation properly. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r--root-tree.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/root-tree.c b/root-tree.c
index bdc85044..858fe2f5 100644
--- a/root-tree.c
+++ b/root-tree.c
@@ -40,10 +40,11 @@ int btrfs_find_last_root(struct btrfs_root *root, u64 objectid,
ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
if (ret < 0)
goto out;
+ if (path->slots[0] == 0)
+ return -ENOENT;
BUG_ON(ret == 0);
l = path->nodes[0];
- BUG_ON(path->slots[0] == 0);
slot = path->slots[0] - 1;
btrfs_item_key_to_cpu(l, &found_key, slot);
if (found_key.objectid != objectid) {