Commit 08f088dd authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba

btrfs: remove unnecessary NULL pointer checks when searching extent maps

The previous and next pointer arguments passed to __tree_search() are
never NULL as the only caller of this function, __lookup_extent_mapping(),
always passes the address of two on stack pointers. So remove the NULL
checks and add assertions to verify the pointers.
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 74333c7d
...@@ -150,6 +150,9 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 offset, ...@@ -150,6 +150,9 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 offset,
struct extent_map *entry; struct extent_map *entry;
struct extent_map *prev_entry = NULL; struct extent_map *prev_entry = NULL;
ASSERT(prev_ret);
ASSERT(next_ret);
while (n) { while (n) {
entry = rb_entry(n, struct extent_map, rb_node); entry = rb_entry(n, struct extent_map, rb_node);
prev = n; prev = n;
...@@ -163,7 +166,6 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 offset, ...@@ -163,7 +166,6 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 offset,
return n; return n;
} }
if (prev_ret) {
orig_prev = prev; orig_prev = prev;
while (prev && offset >= extent_map_end(prev_entry)) { while (prev && offset >= extent_map_end(prev_entry)) {
prev = rb_next(prev); prev = rb_next(prev);
...@@ -171,16 +173,14 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 offset, ...@@ -171,16 +173,14 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 offset,
} }
*prev_ret = prev; *prev_ret = prev;
prev = orig_prev; prev = orig_prev;
}
if (next_ret) {
prev_entry = rb_entry(prev, struct extent_map, rb_node); prev_entry = rb_entry(prev, struct extent_map, rb_node);
while (prev && offset < prev_entry->start) { while (prev && offset < prev_entry->start) {
prev = rb_prev(prev); prev = rb_prev(prev);
prev_entry = rb_entry(prev, struct extent_map, rb_node); prev_entry = rb_entry(prev, struct extent_map, rb_node);
} }
*next_ret = prev; *next_ret = prev;
}
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment