Re: [PATCH] perf tools: fix bug in usage of the basename() function

From: Ingo Molnar
Date: Tue Dec 10 2013 - 07:34:22 EST



* Stephane Eranian <eranian@xxxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/