lkml.org 
[lkml]   [2013]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [GIT PULL 00/21] perf/core improvements and fixes

    * Arnaldo Carvalho de Melo <acme@ghostprotocols.net> wrote:

    > Em Tue, Dec 10, 2013 at 01:18:01PM +0100, Ingo Molnar escreveu:
    > >
    > > * Adrian Hunter <adrian.hunter@intel.com> wrote:
    > >
    > > > -void dso__set_short_name(struct dso *dso, const char *name)
    > > > +void dso__set_short_name(struct dso *dso, const char *name, bool sname_alloc)
    > > > {
    > > > if (name == NULL)
    > > > return;
    > > > + if (dso->sname_alloc)
    > > > + free((char *)dso->short_name);
    > > > + dso->sname_alloc = sname_alloc;
    > >
    > > Calling the function option the same as the field name is asking for
    > > trouble - I'd suggest 'new_sname_alloc' for the parameter, or so.
    > >
    > > And I'd also remove the 'const' from struct dso::short_name, it
    > > probably does not help code generation, because 'dso' is passed in as
    > > const in all the non-lifetime methods anyway.
    >
    > > That way the cast can be dropped from the free().
    >
    > Not that simple, there are multiple places that pass a constant
    > short_name, for instance:
    >
    > machine__get_kernel()
    > kernel = dso__kernel_findnew(machine, vmlinux_name,
    > "[kernel]", DSO_TYPE_KERNEL);
    > dso__set_short_name(dso, short_name);
    >
    > So dso->short_name will point to "[kernel]", which is a const char *.

    Okay, I guess the free() cast is fine then.

    Thanks,

    Ingo


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