From 520da457f9b883e541c36c8f55e7590848b7aa64 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Thu, 24 Aug 2023 19:40:02 -0700 Subject: [PATCH] perf tui slang: Tidy casts Casts were necessary for older versions of libslang, however, these are now 15 years old and so we no longer need to care about supporting them. Tidy the casts and remove unnecessary logic. Move the ENABLE_SLFUTURE_CONST to the libslang.h common include file, and also enable ENABLE_SLFUTURE_VOID. Signed-off-by: Ian Rogers Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Athira Rajeev Cc: Huacai Chen Cc: Ingo Molnar Cc: James Clark Cc: Jiri Olsa Cc: John Garry Cc: K Prateek Nayak Cc: Kajol Jain Cc: Kan Liang Cc: Leo Yan Cc: Mark Rutland Cc: Mike Leach Cc: Ming Wang Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Ravi Bangoria Cc: Sean Christopherson Cc: Suzuki Poulouse Cc: Wei Li Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org Link: https://lore.kernel.org/r/20230825024002.801955-7-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/Build | 2 -- tools/perf/ui/browser.c | 6 +++--- tools/perf/ui/browsers/Build | 5 ----- tools/perf/ui/libslang.h | 20 ++++---------------- tools/perf/ui/tui/helpline.c | 2 +- tools/perf/ui/tui/setup.c | 2 +- tools/perf/ui/tui/util.c | 12 ++++++------ 7 files changed, 15 insertions(+), 34 deletions(-) diff --git a/tools/perf/ui/Build b/tools/perf/ui/Build index 3aff83c..6b6d714 100644 --- a/tools/perf/ui/Build +++ b/tools/perf/ui/Build @@ -10,5 +10,3 @@ CFLAGS_setup.o += -DLIBDIR="BUILD_STR($(LIBDIR))" perf-$(CONFIG_SLANG) += browser.o perf-$(CONFIG_SLANG) += browsers/ perf-$(CONFIG_SLANG) += tui/ - -CFLAGS_browser.o += -DENABLE_SLFUTURE_CONST diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c index 78fb01d..603d112 100644 --- a/tools/perf/ui/browser.c +++ b/tools/perf/ui/browser.c @@ -57,12 +57,12 @@ void ui_browser__gotorc(struct ui_browser *browser, int y, int x) void ui_browser__write_nstring(struct ui_browser *browser __maybe_unused, const char *msg, unsigned int width) { - slsmg_write_nstring(msg, width); + SLsmg_write_nstring(msg, width); } void ui_browser__vprintf(struct ui_browser *browser __maybe_unused, const char *fmt, va_list args) { - slsmg_vprintf(fmt, args); + SLsmg_vprintf(fmt, args); } void ui_browser__printf(struct ui_browser *browser __maybe_unused, const char *fmt, ...) @@ -808,6 +808,6 @@ void ui_browser__init(void) while (ui_browser__colorsets[i].name) { struct ui_browser_colorset *c = &ui_browser__colorsets[i++]; - sltt_set_color(c->colorset, c->name, c->fg, c->bg); + SLtt_set_color(c->colorset, c->name, c->fg, c->bg); } } diff --git a/tools/perf/ui/browsers/Build b/tools/perf/ui/browsers/Build index fdf86f7..7a1d5dd 100644 --- a/tools/perf/ui/browsers/Build +++ b/tools/perf/ui/browsers/Build @@ -4,8 +4,3 @@ perf-y += map.o perf-y += scripts.o perf-y += header.o perf-y += res_sample.o - -CFLAGS_annotate.o += -DENABLE_SLFUTURE_CONST -CFLAGS_hists.o += -DENABLE_SLFUTURE_CONST -CFLAGS_map.o += -DENABLE_SLFUTURE_CONST -CFLAGS_scripts.o += -DENABLE_SLFUTURE_CONST diff --git a/tools/perf/ui/libslang.h b/tools/perf/ui/libslang.h index 991e692..1dff302 100644 --- a/tools/perf/ui/libslang.h +++ b/tools/perf/ui/libslang.h @@ -11,28 +11,16 @@ #define HAVE_LONG_LONG __GLIBC_HAVE_LONG_LONG #endif +/* Enable future slang's corrected function prototypes. */ +#define ENABLE_SLFUTURE_CONST 1 +#define ENABLE_SLFUTURE_VOID 1 + #ifdef HAVE_SLANG_INCLUDE_SUBDIR #include #else #include #endif -#if SLANG_VERSION < 20104 -#define slsmg_printf(msg, args...) \ - SLsmg_printf((char *)(msg), ##args) -#define slsmg_vprintf(msg, vargs) \ - SLsmg_vprintf((char *)(msg), vargs) -#define slsmg_write_nstring(msg, len) \ - SLsmg_write_nstring((char *)(msg), len) -#define sltt_set_color(obj, name, fg, bg) \ - SLtt_set_color(obj,(char *)(name), (char *)(fg), (char *)(bg)) -#else -#define slsmg_printf SLsmg_printf -#define slsmg_vprintf SLsmg_vprintf -#define slsmg_write_nstring SLsmg_write_nstring -#define sltt_set_color SLtt_set_color -#endif - #define SL_KEY_UNTAB 0x1000 #endif /* _PERF_UI_SLANG_H_ */ diff --git a/tools/perf/ui/tui/helpline.c b/tools/perf/ui/tui/helpline.c index db4952f..b394513 100644 --- a/tools/perf/ui/tui/helpline.c +++ b/tools/perf/ui/tui/helpline.c @@ -22,7 +22,7 @@ static void tui_helpline__push(const char *msg) SLsmg_gotorc(SLtt_Screen_Rows - 1, 0); SLsmg_set_color(0); - SLsmg_write_nstring((char *)msg, SLtt_Screen_Cols); + SLsmg_write_nstring(msg, SLtt_Screen_Cols); SLsmg_refresh(); strlcpy(ui_helpline__current, msg, sz); } diff --git a/tools/perf/ui/tui/setup.c b/tools/perf/ui/tui/setup.c index c1886aa..605d9e1 100644 --- a/tools/perf/ui/tui/setup.c +++ b/tools/perf/ui/tui/setup.c @@ -142,7 +142,7 @@ int ui__init(void) goto out; } - SLkp_define_keysym((char *)"^(kB)", SL_KEY_UNTAB); + SLkp_define_keysym("^(kB)", SL_KEY_UNTAB); signal(SIGSEGV, ui__signal_backtrace); signal(SIGFPE, ui__signal_backtrace); diff --git a/tools/perf/ui/tui/util.c b/tools/perf/ui/tui/util.c index 3c51748..e4d322c 100644 --- a/tools/perf/ui/tui/util.c +++ b/tools/perf/ui/tui/util.c @@ -106,7 +106,7 @@ int ui_browser__input_window(const char *title, const char *text, char *input, SLsmg_draw_box(y, x++, nr_lines, max_len); if (title) { SLsmg_gotorc(y, x + 1); - SLsmg_write_string((char *)title); + SLsmg_write_string(title); } SLsmg_gotorc(++y, x); nr_lines -= 7; @@ -117,12 +117,12 @@ int ui_browser__input_window(const char *title, const char *text, char *input, len = 5; while (len--) { SLsmg_gotorc(y + len - 1, x); - SLsmg_write_nstring((char *)" ", max_len); + SLsmg_write_nstring(" ", max_len); } SLsmg_draw_box(y++, x + 1, 3, max_len - 2); SLsmg_gotorc(y + 3, x); - SLsmg_write_nstring((char *)exit_msg, max_len); + SLsmg_write_nstring(exit_msg, max_len); SLsmg_refresh(); mutex_unlock(&ui__lock); @@ -197,7 +197,7 @@ void __ui__info_window(const char *title, const char *text, const char *exit_msg SLsmg_draw_box(y, x++, nr_lines, max_len); if (title) { SLsmg_gotorc(y, x + 1); - SLsmg_write_string((char *)title); + SLsmg_write_string(title); } SLsmg_gotorc(++y, x); if (exit_msg) @@ -207,9 +207,9 @@ void __ui__info_window(const char *title, const char *text, const char *exit_msg nr_lines, max_len, 1); if (exit_msg) { SLsmg_gotorc(y + nr_lines - 2, x); - SLsmg_write_nstring((char *)" ", max_len); + SLsmg_write_nstring(" ", max_len); SLsmg_gotorc(y + nr_lines - 1, x); - SLsmg_write_nstring((char *)exit_msg, max_len); + SLsmg_write_nstring(exit_msg, max_len); } } -- 2.7.4