All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] f2fs: use rb_entry_safe
@ 2016-12-20 13:57 Geliang Tang
  2016-12-20 13:57   ` Geliang Tang
  2016-12-20 13:57 ` [PATCH] timerqueue: " Geliang Tang
  0 siblings, 2 replies; 7+ messages in thread
From: Geliang Tang @ 2016-12-20 13:57 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu; +Cc: Geliang Tang, linux-f2fs-devel, linux-kernel

Use rb_entry_safe() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 fs/f2fs/extent_cache.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
index 4db44da..f79bfb2 100644
--- a/fs/f2fs/extent_cache.c
+++ b/fs/f2fs/extent_cache.c
@@ -311,28 +311,24 @@ static struct extent_node *__lookup_extent_tree_ret(struct extent_tree *et,
 	tmp_node = parent;
 	if (parent && fofs > en->ei.fofs)
 		tmp_node = rb_next(parent);
-	*next_ex = tmp_node ?
-		rb_entry(tmp_node, struct extent_node, rb_node) : NULL;
+	*next_ex = rb_entry_safe(tmp_node, struct extent_node, rb_node);
 
 	tmp_node = parent;
 	if (parent && fofs < en->ei.fofs)
 		tmp_node = rb_prev(parent);
-	*prev_ex = tmp_node ?
-		rb_entry(tmp_node, struct extent_node, rb_node) : NULL;
+	*prev_ex = rb_entry_safe(tmp_node, struct extent_node, rb_node);
 	return NULL;
 
 lookup_neighbors:
 	if (fofs == en->ei.fofs) {
 		/* lookup prev node for merging backward later */
 		tmp_node = rb_prev(&en->rb_node);
-		*prev_ex = tmp_node ?
-			rb_entry(tmp_node, struct extent_node, rb_node) : NULL;
+		*prev_ex = rb_entry_safe(tmp_node, struct extent_node, rb_node);
 	}
 	if (fofs == en->ei.fofs + en->ei.len - 1) {
 		/* lookup next node for merging frontward later */
 		tmp_node = rb_next(&en->rb_node);
-		*next_ex = tmp_node ?
-			rb_entry(tmp_node, struct extent_node, rb_node) : NULL;
+		*next_ex = rb_entry_safe(tmp_node, struct extent_node, rb_node);
 	}
 	return en;
 }
@@ -492,9 +488,8 @@ static unsigned int f2fs_update_extent_tree_range(struct inode *inode,
 		if (!next_en) {
 			struct rb_node *node = rb_next(&en->rb_node);
 
-			next_en = node ?
-				rb_entry(node, struct extent_node, rb_node)
-				: NULL;
+			next_en = rb_entry_safe(node, struct extent_node,
+						rb_node);
 		}
 
 		if (parts)
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] mm/vmalloc.c: use rb_entry_safe
  2016-12-20 13:57 [PATCH] f2fs: use rb_entry_safe Geliang Tang
@ 2016-12-20 13:57   ` Geliang Tang
  2016-12-20 13:57 ` [PATCH] timerqueue: " Geliang Tang
  1 sibling, 0 replies; 7+ messages in thread
From: Geliang Tang @ 2016-12-20 13:57 UTC (permalink / raw)
  To: Andrew Morton, zijun_hu, David Rientjes, Michal Hocko,
	Vladimir Davydov, Chris Wilson
  Cc: Geliang Tang, linux-mm, linux-kernel

Use rb_entry_safe() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 mm/vmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index a558438..b9999fc 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2309,7 +2309,7 @@ EXPORT_SYMBOL_GPL(free_vm_area);
 #ifdef CONFIG_SMP
 static struct vmap_area *node_to_va(struct rb_node *n)
 {
-	return n ? rb_entry(n, struct vmap_area, rb_node) : NULL;
+	return rb_entry_safe(n, struct vmap_area, rb_node);
 }
 
 /**
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] mm/vmalloc.c: use rb_entry_safe
@ 2016-12-20 13:57   ` Geliang Tang
  0 siblings, 0 replies; 7+ messages in thread
From: Geliang Tang @ 2016-12-20 13:57 UTC (permalink / raw)
  To: Andrew Morton, zijun_hu, David Rientjes, Michal Hocko,
	Vladimir Davydov, Chris Wilson
  Cc: Geliang Tang, linux-mm, linux-kernel

Use rb_entry_safe() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 mm/vmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index a558438..b9999fc 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2309,7 +2309,7 @@ EXPORT_SYMBOL_GPL(free_vm_area);
 #ifdef CONFIG_SMP
 static struct vmap_area *node_to_va(struct rb_node *n)
 {
-	return n ? rb_entry(n, struct vmap_area, rb_node) : NULL;
+	return rb_entry_safe(n, struct vmap_area, rb_node);
 }
 
 /**
-- 
2.9.3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] timerqueue: use rb_entry_safe
  2016-12-20 13:57 [PATCH] f2fs: use rb_entry_safe Geliang Tang
  2016-12-20 13:57   ` Geliang Tang
@ 2016-12-20 13:57 ` Geliang Tang
  2017-01-20  7:06   ` [tip:timers/core] timerqueue: Use rb_entry_safe() instead of open-coding it tip-bot for Geliang Tang
  1 sibling, 1 reply; 7+ messages in thread
From: Geliang Tang @ 2016-12-20 13:57 UTC (permalink / raw)
  To: Andrew Morton, John Stultz, Thomas Gleixner; +Cc: Geliang Tang, linux-kernel

Use rb_entry_safe() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 lib/timerqueue.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/timerqueue.c b/lib/timerqueue.c
index 782ae8c..3debca0 100644
--- a/lib/timerqueue.c
+++ b/lib/timerqueue.c
@@ -80,8 +80,7 @@ bool timerqueue_del(struct timerqueue_head *head, struct timerqueue_node *node)
 	if (head->next == node) {
 		struct rb_node *rbn = rb_next(&node->node);
 
-		head->next = rbn ?
-			rb_entry(rbn, struct timerqueue_node, node) : NULL;
+		head->next = rb_entry_safe(rbn, struct timerqueue_node, node);
 	}
 	rb_erase(&node->node, &head->head);
 	RB_CLEAR_NODE(&node->node);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm/vmalloc.c: use rb_entry_safe
  2016-12-20 13:57   ` Geliang Tang
@ 2016-12-20 14:35     ` Michal Hocko
  -1 siblings, 0 replies; 7+ messages in thread
From: Michal Hocko @ 2016-12-20 14:35 UTC (permalink / raw)
  To: Geliang Tang
  Cc: Andrew Morton, zijun_hu, David Rientjes, Vladimir Davydov,
	Chris Wilson, linux-mm, linux-kernel

On Tue 20-12-16 21:57:43, Geliang Tang wrote:
> Use rb_entry_safe() instead of open-coding it.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Acked-by: Michal Hocko <mhocko@suse.com>

> ---
>  mm/vmalloc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index a558438..b9999fc 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -2309,7 +2309,7 @@ EXPORT_SYMBOL_GPL(free_vm_area);
>  #ifdef CONFIG_SMP
>  static struct vmap_area *node_to_va(struct rb_node *n)
>  {
> -	return n ? rb_entry(n, struct vmap_area, rb_node) : NULL;
> +	return rb_entry_safe(n, struct vmap_area, rb_node);
>  }
>  
>  /**
> -- 
> 2.9.3
> 

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm/vmalloc.c: use rb_entry_safe
@ 2016-12-20 14:35     ` Michal Hocko
  0 siblings, 0 replies; 7+ messages in thread
From: Michal Hocko @ 2016-12-20 14:35 UTC (permalink / raw)
  To: Geliang Tang
  Cc: Andrew Morton, zijun_hu, David Rientjes, Vladimir Davydov,
	Chris Wilson, linux-mm, linux-kernel

On Tue 20-12-16 21:57:43, Geliang Tang wrote:
> Use rb_entry_safe() instead of open-coding it.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Acked-by: Michal Hocko <mhocko@suse.com>

> ---
>  mm/vmalloc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index a558438..b9999fc 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -2309,7 +2309,7 @@ EXPORT_SYMBOL_GPL(free_vm_area);
>  #ifdef CONFIG_SMP
>  static struct vmap_area *node_to_va(struct rb_node *n)
>  {
> -	return n ? rb_entry(n, struct vmap_area, rb_node) : NULL;
> +	return rb_entry_safe(n, struct vmap_area, rb_node);
>  }
>  
>  /**
> -- 
> 2.9.3
> 

-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [tip:timers/core] timerqueue: Use rb_entry_safe() instead of open-coding it
  2016-12-20 13:57 ` [PATCH] timerqueue: " Geliang Tang
@ 2017-01-20  7:06   ` tip-bot for Geliang Tang
  0 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Geliang Tang @ 2017-01-20  7:06 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, geliangtang, john.stultz, mingo, akpm, linux-kernel, tglx

Commit-ID:  d852d39432f5d9822dd0ea8760573448338caf41
Gitweb:     http://git.kernel.org/tip/d852d39432f5d9822dd0ea8760573448338caf41
Author:     Geliang Tang <geliangtang@gmail.com>
AuthorDate: Tue, 20 Dec 2016 21:57:44 +0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 20 Jan 2017 08:03:42 +0100

timerqueue: Use rb_entry_safe() instead of open-coding it

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/0d5cf199ac43792df0b6f7e2145545c30fa1dbbe.1482222135.git.geliangtang@gmail.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 lib/timerqueue.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/timerqueue.c b/lib/timerqueue.c
index adc6ee0..4a720ed 100644
--- a/lib/timerqueue.c
+++ b/lib/timerqueue.c
@@ -80,8 +80,7 @@ bool timerqueue_del(struct timerqueue_head *head, struct timerqueue_node *node)
 	if (head->next == node) {
 		struct rb_node *rbn = rb_next(&node->node);
 
-		head->next = rbn ?
-			rb_entry(rbn, struct timerqueue_node, node) : NULL;
+		head->next = rb_entry_safe(rbn, struct timerqueue_node, node);
 	}
 	rb_erase(&node->node, &head->head);
 	RB_CLEAR_NODE(&node->node);

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-01-20  7:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-20 13:57 [PATCH] f2fs: use rb_entry_safe Geliang Tang
2016-12-20 13:57 ` [PATCH] mm/vmalloc.c: " Geliang Tang
2016-12-20 13:57   ` Geliang Tang
2016-12-20 14:35   ` Michal Hocko
2016-12-20 14:35     ` Michal Hocko
2016-12-20 13:57 ` [PATCH] timerqueue: " Geliang Tang
2017-01-20  7:06   ` [tip:timers/core] timerqueue: Use rb_entry_safe() instead of open-coding it tip-bot for Geliang Tang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.