linux-s390.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] s390: cleanup with list_first_entry_or_null()
@ 2016-09-12 18:10 Masahiro Yamada
  2016-09-13  6:47 ` Heiko Carstens
  0 siblings, 1 reply; 2+ messages in thread
From: Masahiro Yamada @ 2016-09-12 18:10 UTC (permalink / raw)
  To: linux-s390
  Cc: Masahiro Yamada, Heiko Carstens, Michael Holzheu, linux-kernel,
	Alexander Kuleshov, Martin Schwidefsky

The combo of list_empty() check and return list_first_entry()
can be replaced with list_first_entry_or_null().

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 arch/s390/kernel/crash_dump.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/s390/kernel/crash_dump.c b/arch/s390/kernel/crash_dump.c
index 29df848..621907d 100644
--- a/arch/s390/kernel/crash_dump.c
+++ b/arch/s390/kernel/crash_dump.c
@@ -71,9 +71,8 @@ struct save_area * __init save_area_alloc(bool is_boot_cpu)
  */
 struct save_area * __init save_area_boot_cpu(void)
 {
-	if (list_empty(&dump_save_areas))
-		return NULL;
-	return list_first_entry(&dump_save_areas, struct save_area, list);
+	return list_first_entry_or_null(&dump_save_areas, struct save_area,
+					list);
 }
 
 /*
-- 
1.9.1

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

* Re: [PATCH] s390: cleanup with list_first_entry_or_null()
  2016-09-12 18:10 [PATCH] s390: cleanup with list_first_entry_or_null() Masahiro Yamada
@ 2016-09-13  6:47 ` Heiko Carstens
  0 siblings, 0 replies; 2+ messages in thread
From: Heiko Carstens @ 2016-09-13  6:47 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-s390, Michael Holzheu, linux-kernel, Alexander Kuleshov,
	Martin Schwidefsky

On Tue, Sep 13, 2016 at 03:10:39AM +0900, Masahiro Yamada wrote:
> The combo of list_empty() check and return list_first_entry()
> can be replaced with list_first_entry_or_null().
> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
> 
>  arch/s390/kernel/crash_dump.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/s390/kernel/crash_dump.c b/arch/s390/kernel/crash_dump.c
> index 29df848..621907d 100644
> --- a/arch/s390/kernel/crash_dump.c
> +++ b/arch/s390/kernel/crash_dump.c
> @@ -71,9 +71,8 @@ struct save_area * __init save_area_alloc(bool is_boot_cpu)
>   */
>  struct save_area * __init save_area_boot_cpu(void)
>  {
> -	if (list_empty(&dump_save_areas))
> -		return NULL;
> -	return list_first_entry(&dump_save_areas, struct save_area, list);
> +	return list_first_entry_or_null(&dump_save_areas, struct save_area,
> +					list);

Applied, however without the line break in order to improve readability.

Thanks!

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

end of thread, other threads:[~2016-09-13  6:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-12 18:10 [PATCH] s390: cleanup with list_first_entry_or_null() Masahiro Yamada
2016-09-13  6:47 ` Heiko Carstens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).