Re: [PATCH 03/13] perf annotate: Move session handling out of __cmd_annotate()

From: Jiri Olsa
Date: Wed Aug 13 2014 - 07:48:44 EST


On Tue, Aug 12, 2014 at 03:40:35PM +0900, Namhyung Kim wrote:

SNIP

>
> @@ -301,6 +281,10 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
> .ordering_requires_timestamps = true,
> },
> };
> + struct perf_data_file file = {
> + .path = input_name,
> + .mode = PERF_DATA_MODE_READ,
> + };
> const struct option options[] = {
> OPT_STRING('i', "input", &input_name, "file",
> "input file name"),
> @@ -308,7 +292,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
> "only consider symbols in these dsos"),
> OPT_STRING('s', "symbol", &annotate.sym_hist_filter, "symbol",
> "symbol to annotate"),
> - OPT_BOOLEAN('f', "force", &annotate.force, "don't complain, do it"),
> + OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"),
> OPT_INCR('v', "verbose", &verbose,
> "be more verbose (show symbol address, etc)"),
> OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
> @@ -341,6 +325,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
> "Show event group information together"),
> OPT_END()
> };
> + int ret;
>
> argc = parse_options(argc, argv, options, annotate_usage, 0);
>
> @@ -353,11 +338,16 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
>
> setup_browser(true);
>
> + annotate.session = perf_session__new(&file, false, &annotate.tool);
> + if (annotate.session == NULL)
> + return -ENOMEM;

I know you're just moving code, but perf_session__new could
fail for more reasons than just ENOMEM, which is the most
unlikely case ;-) -1 is probably better option here

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/