Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753092AbcD1XOl (ORCPT ); Thu, 28 Apr 2016 19:14:41 -0400 Received: from mail.kernel.org ([198.145.29.136]:38010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753045AbcD1XOj (ORCPT ); Thu, 28 Apr 2016 19:14:39 -0400 Date: Fri, 29 Apr 2016 08:14:35 +0900 From: Masami Hiramatsu To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , , Peter Zijlstra , Ingo Molnar , Hemant Kumar , Ananth N Mavinakayanahalli Subject: Re: [PATCH perf/core v5 04/15] perf probe: Add --cache option to cache the probe definitions Message-Id: <20160429081435.2f08d6646d6f909d308bb317@kernel.org> In-Reply-To: <20160428021219.GB15055@sejong.aot.lge.com> References: <20160427183701.23446.15293.stgit@devbox> <20160427183741.23446.1938.stgit@devbox> <20160428021219.GB15055@sejong.aot.lge.com> X-Mailer: Sylpheed 3.4.3 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1388 Lines: 56 On Thu, 28 Apr 2016 11:12:19 +0900 Namhyung Kim wrote: > On Thu, Apr 28, 2016 at 03:37:42AM +0900, Masami Hiramatsu wrote: > > From: Masami Hiramatsu > > > > Add --cache option to cache the probe definitions. This > > just saves the result of the dwarf analysis to probe cache. > > > > Signed-off-by: Masami Hiramatsu > > Signed-off-by: Masami Hiramatsu > > --- > > Changes in v5: > > - Move probe_cache* definitions. (code cleanup) > > > > Changes in v4: > > - Remove cache saving failure message. > > --- > > [snip] > > +static int probe_cache__load(struct probe_cache *pcache) > > +{ > > + struct probe_cache_entry *entry = NULL; > > + char buf[MAX_CMDLEN], *p; > > + int ret = 0; > > + FILE *fp; > > + > > + fp = fdopen(dup(pcache->fd), "r"); > > + while (!feof(fp)) { > > + if (!fgets(buf, MAX_CMDLEN, fp)) > > + break; > > + p = strchr(buf, '\n'); > > + if (p) > > + *p = '\0'; > > + if (buf[0] == '#') { /* #perf_probe_event */ > > + entry = probe_cache_entry__new(NULL); > > The probe_cache_entry__new() can fail. Good catch! > > Thanks, > Namhyung > > > > + entry->spev = strdup(buf + 1); Moreover, if this strdup fail, this goes to return but retvalue is 0... I'll fix this too. Thank you! -- Masami Hiramatsu