ext4: use rb_entry_safe() instead of open-coding it
diff mbox series

Message ID 20190725131658.17187-1-houweitaoo@gmail.com
State New
Headers show
Series
  • ext4: use rb_entry_safe() instead of open-coding it
Related show

Commit Message

Weitao Hou July 25, 2019, 1:16 p.m. UTC
use rb_entry_safe() to make it clean

Signed-off-by: Weitao Hou <houweitaoo@gmail.com>
---
 fs/ext4/extents_status.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Jan Kara Aug. 2, 2019, 11:02 a.m. UTC | #1
On Thu 25-07-19 21:16:58, Weitao Hou wrote:
> use rb_entry_safe() to make it clean
> 
> Signed-off-by: Weitao Hou <houweitaoo@gmail.com>

Thanks for the patch. It looks good. You can add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ext4/extents_status.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
> index 7521de2dcf3a..08ce5ded3538 100644
> --- a/fs/ext4/extents_status.c
> +++ b/fs/ext4/extents_status.c
> @@ -228,8 +228,7 @@ static struct extent_status *__es_tree_search(struct rb_root *root,
>  
>  	if (es && lblk > ext4_es_end(es)) {
>  		node = rb_next(&es->rb_node);
> -		return node ? rb_entry(node, struct extent_status, rb_node) :
> -			      NULL;
> +		return rb_entry_safe(node, struct extent_status, rb_node);
>  	}
>  
>  	return NULL;
> -- 
> 2.18.0
>

Patch
diff mbox series

diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
index 7521de2dcf3a..08ce5ded3538 100644
--- a/fs/ext4/extents_status.c
+++ b/fs/ext4/extents_status.c
@@ -228,8 +228,7 @@  static struct extent_status *__es_tree_search(struct rb_root *root,
 
 	if (es && lblk > ext4_es_end(es)) {
 		node = rb_next(&es->rb_node);
-		return node ? rb_entry(node, struct extent_status, rb_node) :
-			      NULL;
+		return rb_entry_safe(node, struct extent_status, rb_node);
 	}
 
 	return NULL;