All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 10/11] perf tools: Save cmdline arguments earlier
Date: Wed,  9 Dec 2015 13:51:55 -0300	[thread overview]
Message-ID: <1449679916-25311-11-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1449679916-25311-1-git-send-email-acme@kernel.org>

From: Josh Poimboeuf <jpoimboe@redhat.com>

perf_env__set_cmdline() only saves the arguments the first time it's
called.  It doesn't need to be called every time the options and
suboptions are parsed.  Instead it can just be called once.

This also has the advantage of making the option parsing code less
perf-specific so it can be moved out to a library.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/19b76a5aa1b688bd635bd65d80bbc103a978d75e.1449548395.git.jpoimboe@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/perf.c               | 1 +
 tools/perf/util/env.c           | 9 ---------
 tools/perf/util/parse-options.c | 2 --
 3 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 4bee53c3f796..59ea48c7e26c 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -384,6 +384,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
 		use_pager = 1;
 	commit_pager_choice();
 
+	perf_env__set_cmdline(&perf_env, argc, argv);
 	status = p->fn(argc, argv, prefix);
 	exit_browser(status);
 	perf_env__exit(&perf_env);
diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c
index 6af4f7c36820..7dd5939dea2e 100644
--- a/tools/perf/util/env.c
+++ b/tools/perf/util/env.c
@@ -25,15 +25,6 @@ int perf_env__set_cmdline(struct perf_env *env, int argc, const char *argv[])
 {
 	int i;
 
-	/*
-	 * If env->cmdline_argv has already been set, do not override it.  This allows
-	 * a command to set the cmdline, parse args and then call another
-	 * builtin function that implements a command -- e.g, cmd_kvm calling
-	 * cmd_record.
-	 */
-	if (env->cmdline_argv != NULL)
-		return 0;
-
 	/* do not include NULL termination */
 	env->cmdline_argv = calloc(argc, sizeof(char *));
 	if (env->cmdline_argv == NULL)
diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
index 9fca09296eb3..d09aff983581 100644
--- a/tools/perf/util/parse-options.c
+++ b/tools/perf/util/parse-options.c
@@ -501,8 +501,6 @@ int parse_options_subcommand(int argc, const char **argv, const struct option *o
 {
 	struct parse_opt_ctx_t ctx;
 
-	perf_env__set_cmdline(&perf_env, argc, argv);
-
 	/* build usage string if it's not provided */
 	if (subcommands && !usagestr[0]) {
 		struct strbuf buf = STRBUF_INIT;
-- 
2.1.0


  parent reply	other threads:[~2015-12-09 16:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-09 16:51 [GIT PULL 00/11] perf/core improvements and fixes Arnaldo Carvalho de Melo
2015-12-09 16:51 ` [PATCH 01/11] perf tui: Change default selection background color to yellow Arnaldo Carvalho de Melo
2015-12-09 16:51 ` [PATCH 02/11] perf tools: Fix map_groups__clone to put cloned map Arnaldo Carvalho de Melo
2015-12-09 16:51 ` [PATCH 03/11] perf stat: Fix cmd_stat to release cpu_map Arnaldo Carvalho de Melo
2015-12-09 16:51 ` [PATCH 04/11] perf hists: Fix hists_evsel to release hists Arnaldo Carvalho de Melo
2015-12-09 16:51 ` [PATCH 05/11] perf tools: Fix maps__fixup_overlappings to put used maps Arnaldo Carvalho de Melo
2015-12-09 16:51 ` [PATCH 06/11] perf machine: Fix machine.vmlinux_maps to make sure to clear the old one Arnaldo Carvalho de Melo
2015-12-09 16:51 ` [PATCH 07/11] perf tools: Fix write_numa_topology to put cpu_map instead of free Arnaldo Carvalho de Melo
2015-12-09 16:51 ` [PATCH 08/11] perf tools: Remove unused pager_use_color variable Arnaldo Carvalho de Melo
2015-12-09 16:51 ` [PATCH 09/11] perf tools: Move term functions out of util.c Arnaldo Carvalho de Melo
2015-12-09 16:51 ` Arnaldo Carvalho de Melo [this message]
2015-12-09 16:51 ` [PATCH 11/11] perf tools: Move cmd_version() to builtin-version.c Arnaldo Carvalho de Melo
2015-12-10  8:12 ` [GIT PULL 00/11] perf/core improvements and fixes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449679916-25311-11-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=jolsa@redhat.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.