lkml.org 
[lkml]   [2016]   [Jun]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH perf/core v10 09/23] perf probe: Show all cached probes
On Sat, 11 Jun 2016 09:28:09 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> On Thu, 9 Jun 2016 11:22:55 -0300
> Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
>
> > Em Wed, Jun 08, 2016 at 06:30:30PM +0900, Masami Hiramatsu escreveu:
> > > +char *build_id_cache__origname(const char *sbuild_id)
> > > +{
> > > + char *linkname;
> > > + char buf[PATH_MAX];
> > > + char *ret = NULL, *p;
> > > + size_t offs = 5; /* == strlen("../..") */
> > > +
> > > + linkname = build_id_cache__linkname(sbuild_id, NULL, 0);
> > > + if (!linkname)
> > > + return NULL;
> > > +
> > > + if (readlink(linkname, buf, PATH_MAX) < 0)
> > > + goto out;
> > > + /* The link should be "../..<origpath>/<sbuild_id>" */
> > > + p = strrchr(buf, '/'); /* Cut off the "/<sbuild_id>" */
> > > + if (p && (p > buf + offs)) {
> > > + *p = '\0';
> > > + if (buf[offs + 1] == '[')
> > > + offs++; /*
> > > + * This is a DSO name, like [kernel.kallsyms].
> > > + * Skip the first '/', since this is not the
> > > + * cache of a regular file.
> > > + */
> > > + ret = strdup(buf + offs); /* Skip "../..[/]" */
> >
> > strdup can fail.
>
> Ah, right.

In this case, build_id_cache__origname() returns ret immediately(see below),
so we don't need to take reaction about that :)

> > > + }
> > > +out:
> > > + free(linkname);
> > > + return ret;
> > > +}

here, if strdup() fails, this just return NULL. that is OK.

Thanks!
--
Masami Hiramatsu <mhiramat@kernel.org>

\
 
 \ /
  Last update: 2016-06-12 06:01    [W:0.069 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site