diff options
author | Namhyung Kim <namhyung@kernel.org> | 2016-01-09 05:16:29 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-01-12 10:42:08 -0500 |
commit | 34b7b0f95d41d2351a080e774d71085171db90e6 (patch) | |
tree | 065cfa3b53e86cd17ba2b4b13fc0179e58bd9fe4 /tools/perf/util/util.c | |
parent | 090cff3eae8f02395009972d01b5dfdb95bcc327 (diff) |
perf tools: Fallback to srcdir/Documentation/tips.txt
Some people don't install perf, but just use compiled version in the
source. Fallback to lookup the source directory for those poor guys. :)
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1452334589-8782-4-git-send-email-namhyung@kernel.org
[ Make perf_tip() return NULL for ENOENT, making the fallback to really take place ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/util.c')
-rw-r--r-- | tools/perf/util/util.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 88b8f8d21f58..ead9509835d2 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <unistd.h> | 17 | #include <unistd.h> |
18 | #include "callchain.h" | 18 | #include "callchain.h" |
19 | #include "strlist.h" | 19 | #include "strlist.h" |
20 | #include <subcmd/exec-cmd.h> | ||
21 | 20 | ||
22 | struct callchain_param callchain_param = { | 21 | struct callchain_param callchain_param = { |
23 | .mode = CHAIN_GRAPH_ABS, | 22 | .mode = CHAIN_GRAPH_ABS, |
@@ -672,14 +671,16 @@ const char *perf_tip(const char *dirpath) | |||
672 | struct str_node *node; | 671 | struct str_node *node; |
673 | char *tip = NULL; | 672 | char *tip = NULL; |
674 | struct strlist_config conf = { | 673 | struct strlist_config conf = { |
675 | .dirname = system_path(dirpath) , | 674 | .dirname = dirpath, |
675 | .file_only = true, | ||
676 | }; | 676 | }; |
677 | 677 | ||
678 | tips = strlist__new("tips.txt", &conf); | 678 | tips = strlist__new("tips.txt", &conf); |
679 | if (tips == NULL || strlist__nr_entries(tips) == 1) { | 679 | if (tips == NULL) |
680 | tip = (char *)"Cannot find tips.txt file"; | 680 | return errno == ENOENT ? NULL : "Tip: get more memory! ;-p"; |
681 | |||
682 | if (strlist__nr_entries(tips) == 0) | ||
681 | goto out; | 683 | goto out; |
682 | } | ||
683 | 684 | ||
684 | node = strlist__entry(tips, random() % strlist__nr_entries(tips)); | 685 | node = strlist__entry(tips, random() % strlist__nr_entries(tips)); |
685 | if (asprintf(&tip, "Tip: %s", node->s) < 0) | 686 | if (asprintf(&tip, "Tip: %s", node->s) < 0) |