lkml.org 
[lkml]   [2013]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] perf tools: fix bug in usage of the basename() function

* Stephane Eranian <eranian@google.com> wrote:

> >> + base = strdup(basename(lname));
> >> +
> >> + free(lname);
> >> +
> >> + if (!base)
> >> + return;
> >> +
> >> + if (dso->sname_alloc)
> >> + free((char *)dso->short_name);
> >
> > That cast is probably not needed.
> >
> It is with my compiler. It prints out a warning otherwise.

Yeah, see my previous mail, I think having dso->short_name as 'const'
is a mistake, as there are really just two main usecases for methods
that operate on 'struct dso':

- life time affecting (setup/free) methods which need access to all
fields, which don't want dso->short_name as a const (as evidenced
by the cast).

- actual usage methods that get a 'const struct dso' anyway, so they
don't need dso->short_name as a const.

Thanks,

Ingo


\
 
 \ /
  Last update: 2013-12-10 14:01    [W:0.057 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site