From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 01/19] perf tools: Use asprintf() for simple string formatting/allocation
Date: Fri, 26 Feb 2016 20:18:13 -0300 [thread overview]
Message-ID: <1456528711-13793-2-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1456528711-13793-1-git-send-email-acme@kernel.org>
From: Arnaldo Carvalho de Melo <acme@redhat.com>
No need to use strbuf there, its just a simple alloc+formatting, which
asprintf does just fine.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-6q6cxfhk8c8ypg3tfpo0i2iy@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/perf.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 144047c396f0..f6321194937f 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -454,11 +454,12 @@ static void handle_internal_command(int argc, const char **argv)
static void execv_dashed_external(const char **argv)
{
- struct strbuf cmd = STRBUF_INIT;
+ char *cmd;
const char *tmp;
int status;
- strbuf_addf(&cmd, "perf-%s", argv[0]);
+ if (asprintf(&cmd, "perf-%s", argv[0]) < 0)
+ goto do_die;
/*
* argv[0] must be the perf command, but the argv array
@@ -467,7 +468,7 @@ static void execv_dashed_external(const char **argv)
* restore it on error.
*/
tmp = argv[0];
- argv[0] = cmd.buf;
+ argv[0] = cmd;
/*
* if we fail because the command is not found, it is
@@ -475,15 +476,16 @@ static void execv_dashed_external(const char **argv)
*/
status = run_command_v_opt(argv, 0);
if (status != -ERR_RUN_COMMAND_EXEC) {
- if (IS_RUN_COMMAND_ERR(status))
+ if (IS_RUN_COMMAND_ERR(status)) {
+do_die:
die("unable to run '%s'", argv[0]);
+ }
exit(-status);
}
errno = ENOENT; /* as if we called execvp */
argv[0] = tmp;
-
- strbuf_release(&cmd);
+ zfree(&cmd);
}
static int run_argv(int *argcp, const char ***argv)
--
2.5.0
next prev parent reply other threads:[~2016-02-26 23:23 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-26 23:18 [GIT PULL 00/19] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-02-26 23:18 ` Arnaldo Carvalho de Melo [this message]
2016-02-26 23:18 ` [PATCH 02/19] perf jvmti: improve error message in Makefile Arnaldo Carvalho de Melo
2016-02-26 23:18 ` [PATCH 03/19] perf tools: Fix parsing of pmu events with empty list of modifiers Arnaldo Carvalho de Melo
2016-02-26 23:18 ` [PATCH 04/19] perf script: Exception handling when the print fmt is empty Arnaldo Carvalho de Melo
2016-02-26 23:18 ` [PATCH 05/19] perf script: Remove duplicated code and needless script_spec__findnew() Arnaldo Carvalho de Melo
2016-02-26 23:18 ` [PATCH 06/19] perf hists: Add more helper functions for the hierarchy mode Arnaldo Carvalho de Melo
2016-02-26 23:18 ` [PATCH 07/19] perf report: Show message for percent limit on stdio Arnaldo Carvalho de Melo
2016-02-26 23:18 ` [PATCH 08/19] perf hists browser: Cleanup hist_browser__update_percent_limit() Arnaldo Carvalho de Melo
2016-02-26 23:18 ` [PATCH 09/19] perf hists browser: Show message for percent limit Arnaldo Carvalho de Melo
2016-02-26 23:18 ` [PATCH 10/19] perf report: Show message for percent limit on gtk Arnaldo Carvalho de Melo
2016-02-26 23:18 ` [PATCH 11/19] perf hists: Fix comparing of dynamic entries Arnaldo Carvalho de Melo
2016-02-26 23:18 ` [PATCH 12/19] perf report: Fix indentation of dynamic entries in hierarchy Arnaldo Carvalho de Melo
2016-02-26 23:18 ` [PATCH 13/19] perf report: Left align " Arnaldo Carvalho de Melo
2016-02-26 23:18 ` [PATCH 14/19] perf hists: Fix dynamic entry display " Arnaldo Carvalho de Melo
2016-02-26 23:18 ` [PATCH 15/19] perf report: Update column width of dynamic entries Arnaldo Carvalho de Melo
2016-02-26 23:18 ` [PATCH 16/19] perf config: Bring perf_default_config to the very beginning at main() Arnaldo Carvalho de Melo
2016-02-26 23:18 ` [PATCH 17/19] perf tools: Only set filter for tracepoints events Arnaldo Carvalho de Melo
2016-02-26 23:18 ` [PATCH 18/19] perf trace: Call bpf__apply_obj_config in 'perf trace' Arnaldo Carvalho de Melo
2016-02-26 23:18 ` [PATCH 19/19] perf trace: Print content of bpf-output event Arnaldo Carvalho de Melo
2016-02-27 9:36 ` [GIT PULL 00/19] 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=1456528711-13793-2-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=wangnan0@huawei.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).