diff options
| author | David Sterba <[email protected]> | 2025-03-27 16:19:18 +0000 |
|---|---|---|
| committer | David Sterba <[email protected]> | 2025-05-15 12:30:40 +0000 |
| commit | 6aa79c4f25197cc54479dc87d79ecd45571fb062 (patch) | |
| tree | 9a117262edd3e1541f3ef70c40fd1734aaadb265 /fs/btrfs/extent-io-tree.c | |
| parent | btrfs: pass a pointer to get_range_bits() to cache first search result (diff) | |
| download | kernel-6aa79c4f25197cc54479dc87d79ecd45571fb062.tar.gz kernel-6aa79c4f25197cc54479dc87d79ecd45571fb062.zip | |
btrfs: use rb_entry_safe() where possible to simplify code
Simplify conditionally reading an rb_entry(), there's the
rb_entry_safe() helper that checks the node pointer for NULL so we don't
have to write it explicitly.
Reviewed-by: Johannes Thumshirn <[email protected]>
Signed-off-by: David Sterba <[email protected]>
Diffstat (limited to 'fs/btrfs/extent-io-tree.c')
| -rw-r--r-- | fs/btrfs/extent-io-tree.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c index 7ae24a533404..a9b163269252 100644 --- a/fs/btrfs/extent-io-tree.c +++ b/fs/btrfs/extent-io-tree.c @@ -222,20 +222,14 @@ static inline struct extent_state *next_state(struct extent_state *state) { struct rb_node *next = rb_next(&state->rb_node); - if (next) - return rb_entry(next, struct extent_state, rb_node); - else - return NULL; + return rb_entry_safe(next, struct extent_state, rb_node); } static inline struct extent_state *prev_state(struct extent_state *state) { struct rb_node *next = rb_prev(&state->rb_node); - if (next) - return rb_entry(next, struct extent_state, rb_node); - else - return NULL; + return rb_entry_safe(next, struct extent_state, rb_node); } /* |
