diff options
author | Josh Poimboeuf <jpoimboe@redhat.com> | 2015-12-15 09:39:36 -0600 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-12-16 21:33:13 -0300 |
commit | 901421a5bdf605d24c278825cdd032cd6038bcb8 (patch) | |
tree | e38d011aa6ff9c348a6ea7d3c9e664fef54b237f /tools/perf/util/exec_cmd.c | |
parent | 096d35585b4fce7d3ee9b8b34314f39f49491ab1 (diff) | |
download | linux-901421a5bdf605d24c278825cdd032cd6038bcb8.tar.gz linux-901421a5bdf605d24c278825cdd032cd6038bcb8.tar.bz2 linux-901421a5bdf605d24c278825cdd032cd6038bcb8.zip |
perf tools: Remove subcmd dependencies on strbuf
Introduce and use new astrcat() and astrcatf() functions which replace
the strbuf functionality for subcmd.
For now they duplicate strbuf's die-on-allocation-error policy.
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/957d207e1254406fa11fc2e405e75a7e405aad8f.1450193761.git.jpoimboe@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/exec_cmd.c')
-rw-r--r-- | tools/perf/util/exec_cmd.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/tools/perf/util/exec_cmd.c b/tools/perf/util/exec_cmd.c index b935e4ce62a2..65d86dcaa984 100644 --- a/tools/perf/util/exec_cmd.c +++ b/tools/perf/util/exec_cmd.c @@ -4,6 +4,7 @@ #include "subcmd-config.h" #include <string.h> +#include "subcmd-util.h" #define MAX_ARGS 32 @@ -21,14 +22,14 @@ void exec_cmd_init(const char *exec_name, const char *prefix, char *system_path(const char *path) { - struct strbuf d = STRBUF_INIT; + char *buf = NULL; if (is_absolute_path(path)) return strdup(path); - strbuf_addf(&d, "%s/%s", subcmd_config.prefix, path); - path = strbuf_detach(&d, NULL); - return (char *)path; + astrcatf(&buf, "%s/%s", subcmd_config.prefix, path); + + return buf; } const char *perf_extract_argv0_path(const char *argv0) @@ -75,22 +76,22 @@ char *perf_exec_path(void) return system_path(subcmd_config.exec_path); } -static void add_path(struct strbuf *out, const char *path) +static void add_path(char **out, const char *path) { if (path && *path) { if (is_absolute_path(path)) - strbuf_addstr(out, path); + astrcat(out, path); else - strbuf_addstr(out, make_nonrelative_path(path)); + astrcat(out, make_nonrelative_path(path)); - strbuf_addch(out, PATH_SEP); + astrcat(out, ":"); } } void setup_path(void) { const char *old_path = getenv("PATH"); - struct strbuf new_path = STRBUF_INIT; + char *new_path = NULL; char *tmp = perf_exec_path(); add_path(&new_path, tmp); @@ -98,13 +99,13 @@ void setup_path(void) free(tmp); if (old_path) - strbuf_addstr(&new_path, old_path); + astrcat(&new_path, old_path); else - strbuf_addstr(&new_path, "/usr/local/bin:/usr/bin:/bin"); + astrcat(&new_path, "/usr/local/bin:/usr/bin:/bin"); - setenv("PATH", new_path.buf, 1); + setenv("PATH", new_path, 1); - strbuf_release(&new_path); + free(new_path); } static const char **prepare_perf_cmd(const char **argv) |