Skip to content

Commit 520da45

Browse files
captain5050acmel
authored andcommitted
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 <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.g.garry@oracle.com> Cc: K Prateek Nayak <kprateek.nayak@amd.com> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mike Leach <mike.leach@linaro.org> Cc: Ming Wang <wangming01@loongson.cn> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Sean Christopherson <seanjc@google.com> Cc: Suzuki Poulouse <suzuki.poulose@arm.com> Cc: Wei Li <liwei391@huawei.com> Cc: Will Deacon <will@kernel.org> 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 <acme@redhat.com>
1 parent 7512e96 commit 520da45

File tree

7 files changed

+15
-34
lines changed

7 files changed

+15
-34
lines changed

tools/perf/ui/Build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@ CFLAGS_setup.o += -DLIBDIR="BUILD_STR($(LIBDIR))"
1010
perf-$(CONFIG_SLANG) += browser.o
1111
perf-$(CONFIG_SLANG) += browsers/
1212
perf-$(CONFIG_SLANG) += tui/
13-
14-
CFLAGS_browser.o += -DENABLE_SLFUTURE_CONST

tools/perf/ui/browser.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ void ui_browser__gotorc(struct ui_browser *browser, int y, int x)
5757
void ui_browser__write_nstring(struct ui_browser *browser __maybe_unused, const char *msg,
5858
unsigned int width)
5959
{
60-
slsmg_write_nstring(msg, width);
60+
SLsmg_write_nstring(msg, width);
6161
}
6262

6363
void ui_browser__vprintf(struct ui_browser *browser __maybe_unused, const char *fmt, va_list args)
6464
{
65-
slsmg_vprintf(fmt, args);
65+
SLsmg_vprintf(fmt, args);
6666
}
6767

6868
void ui_browser__printf(struct ui_browser *browser __maybe_unused, const char *fmt, ...)
@@ -808,6 +808,6 @@ void ui_browser__init(void)
808808

809809
while (ui_browser__colorsets[i].name) {
810810
struct ui_browser_colorset *c = &ui_browser__colorsets[i++];
811-
sltt_set_color(c->colorset, c->name, c->fg, c->bg);
811+
SLtt_set_color(c->colorset, c->name, c->fg, c->bg);
812812
}
813813
}

tools/perf/ui/browsers/Build

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,3 @@ perf-y += map.o
44
perf-y += scripts.o
55
perf-y += header.o
66
perf-y += res_sample.o
7-
8-
CFLAGS_annotate.o += -DENABLE_SLFUTURE_CONST
9-
CFLAGS_hists.o += -DENABLE_SLFUTURE_CONST
10-
CFLAGS_map.o += -DENABLE_SLFUTURE_CONST
11-
CFLAGS_scripts.o += -DENABLE_SLFUTURE_CONST

tools/perf/ui/libslang.h

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,16 @@
1111
#define HAVE_LONG_LONG __GLIBC_HAVE_LONG_LONG
1212
#endif
1313

14+
/* Enable future slang's corrected function prototypes. */
15+
#define ENABLE_SLFUTURE_CONST 1
16+
#define ENABLE_SLFUTURE_VOID 1
17+
1418
#ifdef HAVE_SLANG_INCLUDE_SUBDIR
1519
#include <slang/slang.h>
1620
#else
1721
#include <slang.h>
1822
#endif
1923

20-
#if SLANG_VERSION < 20104
21-
#define slsmg_printf(msg, args...) \
22-
SLsmg_printf((char *)(msg), ##args)
23-
#define slsmg_vprintf(msg, vargs) \
24-
SLsmg_vprintf((char *)(msg), vargs)
25-
#define slsmg_write_nstring(msg, len) \
26-
SLsmg_write_nstring((char *)(msg), len)
27-
#define sltt_set_color(obj, name, fg, bg) \
28-
SLtt_set_color(obj,(char *)(name), (char *)(fg), (char *)(bg))
29-
#else
30-
#define slsmg_printf SLsmg_printf
31-
#define slsmg_vprintf SLsmg_vprintf
32-
#define slsmg_write_nstring SLsmg_write_nstring
33-
#define sltt_set_color SLtt_set_color
34-
#endif
35-
3624
#define SL_KEY_UNTAB 0x1000
3725

3826
#endif /* _PERF_UI_SLANG_H_ */

tools/perf/ui/tui/helpline.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static void tui_helpline__push(const char *msg)
2222

2323
SLsmg_gotorc(SLtt_Screen_Rows - 1, 0);
2424
SLsmg_set_color(0);
25-
SLsmg_write_nstring((char *)msg, SLtt_Screen_Cols);
25+
SLsmg_write_nstring(msg, SLtt_Screen_Cols);
2626
SLsmg_refresh();
2727
strlcpy(ui_helpline__current, msg, sz);
2828
}

tools/perf/ui/tui/setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ int ui__init(void)
142142
goto out;
143143
}
144144

145-
SLkp_define_keysym((char *)"^(kB)", SL_KEY_UNTAB);
145+
SLkp_define_keysym("^(kB)", SL_KEY_UNTAB);
146146

147147
signal(SIGSEGV, ui__signal_backtrace);
148148
signal(SIGFPE, ui__signal_backtrace);

tools/perf/ui/tui/util.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ int ui_browser__input_window(const char *title, const char *text, char *input,
106106
SLsmg_draw_box(y, x++, nr_lines, max_len);
107107
if (title) {
108108
SLsmg_gotorc(y, x + 1);
109-
SLsmg_write_string((char *)title);
109+
SLsmg_write_string(title);
110110
}
111111
SLsmg_gotorc(++y, x);
112112
nr_lines -= 7;
@@ -117,12 +117,12 @@ int ui_browser__input_window(const char *title, const char *text, char *input,
117117
len = 5;
118118
while (len--) {
119119
SLsmg_gotorc(y + len - 1, x);
120-
SLsmg_write_nstring((char *)" ", max_len);
120+
SLsmg_write_nstring(" ", max_len);
121121
}
122122
SLsmg_draw_box(y++, x + 1, 3, max_len - 2);
123123

124124
SLsmg_gotorc(y + 3, x);
125-
SLsmg_write_nstring((char *)exit_msg, max_len);
125+
SLsmg_write_nstring(exit_msg, max_len);
126126
SLsmg_refresh();
127127

128128
mutex_unlock(&ui__lock);
@@ -197,7 +197,7 @@ void __ui__info_window(const char *title, const char *text, const char *exit_msg
197197
SLsmg_draw_box(y, x++, nr_lines, max_len);
198198
if (title) {
199199
SLsmg_gotorc(y, x + 1);
200-
SLsmg_write_string((char *)title);
200+
SLsmg_write_string(title);
201201
}
202202
SLsmg_gotorc(++y, x);
203203
if (exit_msg)
@@ -207,9 +207,9 @@ void __ui__info_window(const char *title, const char *text, const char *exit_msg
207207
nr_lines, max_len, 1);
208208
if (exit_msg) {
209209
SLsmg_gotorc(y + nr_lines - 2, x);
210-
SLsmg_write_nstring((char *)" ", max_len);
210+
SLsmg_write_nstring(" ", max_len);
211211
SLsmg_gotorc(y + nr_lines - 1, x);
212-
SLsmg_write_nstring((char *)exit_msg, max_len);
212+
SLsmg_write_nstring(exit_msg, max_len);
213213
}
214214
}
215215

0 commit comments

Comments
 (0)