From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756842AbbLDWCM (ORCPT ); Fri, 4 Dec 2015 17:02:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:24966 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756670AbbLDV7o (ORCPT ); Fri, 4 Dec 2015 16:59:44 -0500 From: Josh Poimboeuf To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org Subject: [PATCH 07/13] perf: Save cmdline arguments earlier Date: Fri, 4 Dec 2015 15:59:18 -0600 Message-Id: <3617c269382c2f7d1a7d1b9a7e1940d683167a58.1449265570.git.jpoimboe@redhat.com> In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 bcf4fab..c57e447 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 6af4f7c..7dd5939 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 9937e91..735c8c8 100644 --- a/tools/perf/util/parse-options.c +++ b/tools/perf/util/parse-options.c @@ -506,8 +506,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.4.3