Re: [PATCH 1/9] perf report: Count number of entries and samples separately

From: Jiri Olsa
Date: Tue Apr 22 2014 - 12:43:54 EST


On Tue, Apr 22, 2014 at 05:49:43PM +0900, Namhyung Kim wrote:
> Those stats are counted counted in multiple places so that they can
> confuse readers of the code. This is a preparation of later change
> and do not intend any functional difference.
>
> Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
> ---

SNIP

>
> /* Non-group events are considered as leader */
> if (symbol_conf.event_group &&
> @@ -526,7 +533,7 @@ static u64 report__collapse_hists(struct report *rep)
>
> ui_progress__finish();
>
> - return nr_samples;
> + return rep->nr_samples;

so this ^^^ is the only usage for rep->nr_samples right?

and the output from report__collapse_hists is used
as a bool if we have at least 1 sample:

nr_samples = report__collapse_hists(rep);

if (session_done())
return 0;

if (nr_samples == 0) {
ui__error("The %s file has no samples!\n", file->path);
return 0;
}

I think report__collapse_hists does not need to return anything
and above code could use (rep->nr_entries > 0) instead, like:

report__collapse_hists(rep);

if (session_done())
return 0;

if (rep->nr_entries == 0) {
ui__error("The %s file has no samples!\n", file->path);
return 0;
}

and we could get rid of rep->nr_samples

thanks,
jirka
--
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/