perf report/top TUI: Fix title line formatting

In d10ec006 ("perf hists browser: Allow passing an initial hotkey")
the hist_entry__title() call was cut'n'pasted to a function where the
'title' variable is a pointer, not an array, so the sizeof(title)
continues syntactically valid but ends up reducing the real size of the
buffer where to format the first line in the screen to 8 bytes, which
makes the formatting at the title at each refresh to produce just the
string "Samples ", duh, fix it by passing the size of the buffer.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Fixes: d10ec006 ("perf hists browser: Allow passing an initial hotkey")
Link: http://lore.kernel.org/lkml/20200330154314.GB4576@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 2605af0f
...@@ -677,7 +677,7 @@ static int hist_browser__title(struct hist_browser *browser, char *bf, size_t si ...@@ -677,7 +677,7 @@ static int hist_browser__title(struct hist_browser *browser, char *bf, size_t si
return browser->title ? browser->title(browser, bf, size) : 0; return browser->title ? browser->title(browser, bf, size) : 0;
} }
static int hist_browser__handle_hotkey(struct hist_browser *browser, bool warn_lost_event, char *title, int key) static int hist_browser__handle_hotkey(struct hist_browser *browser, bool warn_lost_event, char *title, size_t size, int key)
{ {
switch (key) { switch (key) {
case K_TIMER: { case K_TIMER: {
...@@ -703,7 +703,7 @@ static int hist_browser__handle_hotkey(struct hist_browser *browser, bool warn_l ...@@ -703,7 +703,7 @@ static int hist_browser__handle_hotkey(struct hist_browser *browser, bool warn_l
ui_browser__warn_lost_events(&browser->b); ui_browser__warn_lost_events(&browser->b);
} }
hist_browser__title(browser, title, sizeof(title)); hist_browser__title(browser, title, size);
ui_browser__show_title(&browser->b, title); ui_browser__show_title(&browser->b, title);
break; break;
} }
...@@ -764,13 +764,13 @@ int hist_browser__run(struct hist_browser *browser, const char *help, ...@@ -764,13 +764,13 @@ int hist_browser__run(struct hist_browser *browser, const char *help,
if (ui_browser__show(&browser->b, title, "%s", help) < 0) if (ui_browser__show(&browser->b, title, "%s", help) < 0)
return -1; return -1;
if (key && hist_browser__handle_hotkey(browser, warn_lost_event, title, key)) if (key && hist_browser__handle_hotkey(browser, warn_lost_event, title, sizeof(title), key))
goto out; goto out;
while (1) { while (1) {
key = ui_browser__run(&browser->b, delay_secs); key = ui_browser__run(&browser->b, delay_secs);
if (hist_browser__handle_hotkey(browser, warn_lost_event, title, key)) if (hist_browser__handle_hotkey(browser, warn_lost_event, title, sizeof(title), key))
break; break;
} }
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment