From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751839AbdKVIcZ (ORCPT ); Wed, 22 Nov 2017 03:32:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57720 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751799AbdKVIcY (ORCPT ); Wed, 22 Nov 2017 03:32:24 -0500 Date: Wed, 22 Nov 2017 09:32:20 +0100 From: Jiri Olsa To: "Jin, Yao" Cc: Ravi Bangoria , acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com Subject: Re: [PATCH v1 3/9] perf util: Reconstruct rblist for supporting per-thread shadow stats Message-ID: <20171122083220.GC30707@krava> References: <1511189024-19908-1-git-send-email-yao.jin@linux.intel.com> <1511189024-19908-4-git-send-email-yao.jin@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 22 Nov 2017 08:32:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 22, 2017 at 02:57:12PM +0800, Jin, Yao wrote: > > > On 11/22/2017 2:31 PM, Ravi Bangoria wrote: > > > > On 11/20/2017 08:13 PM, Jin Yao wrote: > > > @@ -76,6 +97,17 @@ static struct rb_node *saved_value_new(struct > > > rblist *rblist __maybe_unused, > > >       return &nd->rb_node; > > >   } > > > > > > +static void saved_value_delete(struct rblist *rblist __maybe_unused, > > > +                   struct rb_node *rb_node) > > > +{ > > > +    struct saved_value *v = container_of(rb_node, > > > +                         struct saved_value, > > > +                         rb_node); > > > + > > > +    if (v) > > > +        free(v); > > > +} > > > > Do we really need if(v) ? > > > > Thanks, > > Ravi > > > > Hi Ravi, > > Looks it doesn't need if(v). > > I put if(v) here is from my coding habits (checking pointer before free). > > It's OK for me if you think the code should be removed. you could add BUG_ON(!rb_node); jirka