File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 2828#include "util/tool.h"
2929
3030#include <subcmd/parse-options.h>
31+ #include <subcmd/exec-cmd.h>
3132#include "util/parse-events.h"
3233
3334#include "util/thread.h"
@@ -433,7 +434,14 @@ static int report__browse_hists(struct report *rep)
433434 int ret ;
434435 struct perf_session * session = rep -> session ;
435436 struct perf_evlist * evlist = session -> evlist ;
436- const char * help = perf_tip (TIPDIR );
437+ const char * help = perf_tip (system_path (TIPDIR ));
438+
439+ if (help == NULL ) {
440+ /* fallback for people who don't install perf ;-) */
441+ help = perf_tip (DOCDIR );
442+ if (help == NULL )
443+ help = "Cannot load tips.txt file, please install perf!" ;
444+ }
437445
438446 switch (use_browser ) {
439447 case 1 :
Original file line number Diff line number Diff line change 1717#include <unistd.h>
1818#include "callchain.h"
1919#include "strlist.h"
20- #include <subcmd/exec-cmd.h>
2120
2221struct callchain_param callchain_param = {
2322 .mode = CHAIN_GRAPH_ABS ,
@@ -672,14 +671,16 @@ const char *perf_tip(const char *dirpath)
672671 struct str_node * node ;
673672 char * tip = NULL ;
674673 struct strlist_config conf = {
675- .dirname = system_path (dirpath ) ,
674+ .dirname = dirpath ,
675+ .file_only = true,
676676 };
677677
678678 tips = strlist__new ("tips.txt" , & conf );
679- if (tips == NULL || strlist__nr_entries (tips ) == 1 ) {
680- tip = (char * )"Cannot find tips.txt file" ;
679+ if (tips == NULL )
680+ return errno == ENOENT ? NULL : "Tip: get more memory! ;-p" ;
681+
682+ if (strlist__nr_entries (tips ) == 0 )
681683 goto out ;
682- }
683684
684685 node = strlist__entry (tips , random () % strlist__nr_entries (tips ));
685686 if (asprintf (& tip , "Tip: %s" , node -> s ) < 0 )
You can’t perform that action at this time.
0 commit comments