Re: [PATCH 05/15 V3] perf, c2c: Rework setup code to prepare for features

From: Namhyung Kim
Date: Tue Apr 08 2014 - 03:18:51 EST


On Mon, 24 Mar 2014 15:36:56 -0400, Don Zickus wrote:
> A basic patch that re-arranges some of the c2c code and adds a couple
> of small features to lay the ground work for the rest of the patch
> series.
>
> Changes include:
>
> o reworking the report path
> o replace preprocess_sample with simpler calls
> o rework raw output to handle separators
> o remove phys id gunk
> o add some generic options

[SNIP]
>
> + return fprintf(fp, fmt,
> + tag, sep,
> + reason ?: "valid record", sep,
> + sample->pid, sep,
> + sample->tid, sep,
> + sample->cpu, sep,
> + sample->ip, sep,
> + sample->addr, sep,
> + sample->weight, sep,
> + sample->data_src, sep,
> + data_src, sep,
> + map ? (map->dso ? map->dso->long_name : "???") : "???",

How about using this instead?

(map && map->dso) ? map->dso->long_name : "???".


> + mi->iaddr.sym ? mi->iaddr.sym->name : "???");
> }
>
> static int perf_c2c__process_load_store(struct perf_c2c *c2c,
> + struct addr_location *al,
> struct perf_sample *sample,
> - struct addr_location *al)
> + struct perf_evsel *evsel)
> {
> - if (c2c->raw_records)
> - perf_sample__fprintf(sample, ' ', "raw input", al, stdout);
> + struct mem_info *mi;
> +
> + mi = sample__resolve_mem(sample, al);
> + if (!mi)
> + return -ENOMEM;
> +
> + if (c2c->raw_records) {
> + perf_sample__fprintf(sample, ' ', "raw input", mi, stdout);
> + free(mi);
> + return 0;
> + }

It seems the 'mi' should be freed here as well?

>
> return 0;
> }


[SNIP]
> +static int perf_c2c__process_events(struct perf_session *session,
> + struct perf_c2c *c2c)
> +{
> + int err = -1;

No need to set.

> +
> + err = perf_session__process_events(session, &c2c->tool);
> + if (err) {
> + pr_err("Failed to process count events, error %d\n", err);
> + goto err;

Unnecessary goto.

Thanks,
Namhyung


> }
>
> +err:
> return err;
> }
--
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/