Messages in this thread | | | Date | Tue, 10 Dec 2013 13:34:11 +0100 | From | Ingo Molnar <> | Subject | Re: [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
| |