From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751382AbcKFEDe (ORCPT ); Sun, 6 Nov 2016 00:03:34 -0400 Received: from mail.kernel.org ([198.145.29.136]:59536 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751008AbcKFEDe (ORCPT ); Sun, 6 Nov 2016 00:03:34 -0400 Date: Sat, 5 Nov 2016 22:03:30 -0600 From: Arnaldo Carvalho de Melo To: Masahiro Yamada Cc: Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Linux Kernel Mailing List , Andi Kleen , Eric Engestrom , He Kuang , Jiri Olsa Subject: Re: [PATCH] perf thread: cleanup with list_first_entry_or_null() Message-ID: <20161106040330.GA12125@kernel.org> References: <1473704975-4636-1-git-send-email-yamada.masahiro@socionext.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Sun, Nov 06, 2016 at 12:00:22PM +0900, Masahiro Yamada escreveu: > Hi maintainers, > > Does this patch look good? >>From a quick look it seems ok, I'll try and process it when back home. - Arnaldo > 2016-09-13 3:29 GMT+09:00 Masahiro Yamada : > > 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 > > --- > > > > tools/perf/util/thread.c | 5 +---- > > 1 file changed, 1 insertion(+), 4 deletions(-) > > > > diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c > > index 8b10a55..ea951df 100644 > > --- a/tools/perf/util/thread.c > > +++ b/tools/perf/util/thread.c > > @@ -107,10 +107,7 @@ void thread__put(struct thread *thread) > > > > struct comm *thread__comm(const struct thread *thread) > > { > > - if (list_empty(&thread->comm_list)) > > - return NULL; > > - > > - return list_first_entry(&thread->comm_list, struct comm, list); > > + return list_first_entry_or_null(&thread->comm_list, struct comm, list); > > } > > > > struct comm *thread__exec_comm(const struct thread *thread) > > -- > > 1.9.1 > > > > > > -- > Best Regards > Masahiro Yamada