Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tui: Add workaround for slang < 2.1.4

Older versions of the slang library didn't used the 'const' specifier,
causing problems with modern compilers of this kind:

util/newt.c:252: error: passing argument 1 of ‘SLsmg_printf’ discards
qualifiers from pointer target type

Fix it by using some wrappers that when needed const the affected
parameters back to plain (char *).

Reported-by: Lin Ming <ming.m.lin@intel.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Lin Ming <ming.m.lin@intel.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <20100517145421.GD29052@ghostprotocols.net>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+21 -10
+21 -10
tools/perf/util/newt.c
··· 14 14 #include "sort.h" 15 15 #include "symbol.h" 16 16 17 + #if SLANG_VERSION < 20104 18 + #define slsmg_printf(msg, args...) SLsmg_printf((char *)msg, ##args) 19 + #define slsmg_write_nstring(msg, len) SLsmg_write_nstring((char *)msg, len) 20 + #define sltt_set_color(obj, name, fg, bg) SLtt_set_color(obj,(char *)name,\ 21 + (char *)fg, (char *)bg) 22 + #else 23 + #define slsmg_printf SLsmg_printf 24 + #define slsmg_write_nstring SLsmg_write_nstring 25 + #define sltt_set_color SLtt_set_color 26 + #endif 27 + 17 28 struct ui_progress { 18 29 newtComponent form, scale; 19 30 }; ··· 303 292 304 293 color = ui_browser__percent_color(percent, current_entry); 305 294 SLsmg_set_color(color); 306 - SLsmg_printf(" %7.2f ", percent); 295 + slsmg_printf(" %7.2f ", percent); 307 296 if (!current_entry) 308 297 SLsmg_set_color(HE_COLORSET_CODE); 309 298 } else { 310 299 int color = ui_browser__percent_color(0, current_entry); 311 300 SLsmg_set_color(color); 312 - SLsmg_write_nstring(" ", 9); 301 + slsmg_write_nstring(" ", 9); 313 302 } 314 303 315 304 SLsmg_write_char(':'); 316 - SLsmg_write_nstring(" ", 8); 305 + slsmg_write_nstring(" ", 8); 317 306 if (!*self->line) 318 - SLsmg_write_nstring(" ", width - 18); 307 + slsmg_write_nstring(" ", width - 18); 319 308 else 320 - SLsmg_write_nstring(self->line, width - 18); 309 + slsmg_write_nstring(self->line, width - 18); 321 310 322 311 return 0; 323 312 } ··· 1065 1054 newtInit(); 1066 1055 newtCls(); 1067 1056 ui_helpline__puts(" "); 1068 - SLtt_set_color(HE_COLORSET_TOP, NULL, c->topColorFg, c->topColorBg); 1069 - SLtt_set_color(HE_COLORSET_MEDIUM, NULL, c->mediumColorFg, c->mediumColorBg); 1070 - SLtt_set_color(HE_COLORSET_NORMAL, NULL, c->normalColorFg, c->normalColorBg); 1071 - SLtt_set_color(HE_COLORSET_SELECTED, NULL, c->selColorFg, c->selColorBg); 1072 - SLtt_set_color(HE_COLORSET_CODE, NULL, c->codeColorFg, c->codeColorBg); 1057 + sltt_set_color(HE_COLORSET_TOP, NULL, c->topColorFg, c->topColorBg); 1058 + sltt_set_color(HE_COLORSET_MEDIUM, NULL, c->mediumColorFg, c->mediumColorBg); 1059 + sltt_set_color(HE_COLORSET_NORMAL, NULL, c->normalColorFg, c->normalColorBg); 1060 + sltt_set_color(HE_COLORSET_SELECTED, NULL, c->selColorFg, c->selColorBg); 1061 + sltt_set_color(HE_COLORSET_CODE, NULL, c->codeColorFg, c->codeColorBg); 1073 1062 } 1074 1063 1075 1064 void exit_browser(bool wait_for_ok)