From: Cyrill Gorcunov Date: Sat, 6 Nov 2010 08:47:24 +0000 (+0300) Subject: perf, ui: Eliminate stack-smashing protection compiler complaint X-Git-Tag: v5.15~27475^2~10 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=a3da8e451321c31d88cebd12c234d0aac2a1cc35;p=mirror_ubuntu-kernels.git perf, ui: Eliminate stack-smashing protection compiler complaint The gcc complains about small auto-var strings being allocated from stack space. Make them const to avoid this: | CC util/ui/util.o | cc1: warnings being treated as errors | util/ui/util.c: In function ‘ui__dialog_yesno’: | util/ui/util.c:108: error: not protecting function: no buffer at least 8 bytes long | make: *** [util/ui/util.o] Error 1 The real bug is in the newtWinChoice() ABI - but that's an externality we cannot fix here, so we use this workaround. Signed-off-by: Cyrill Gorcunov Acked-by: Frédéric Weisbecker Cc: Arnaldo Carvalho de Melo LKML-Reference: <20101106084724.GA5956@lenovo> Signed-off-by: Ingo Molnar --- diff --git a/tools/perf/util/ui/util.c b/tools/perf/util/ui/util.c index 9706d9d40279..056c69521a38 100644 --- a/tools/perf/util/ui/util.c +++ b/tools/perf/util/ui/util.c @@ -104,9 +104,10 @@ out_destroy_form: return rc; } +static const char yes[] = "Yes", no[] = "No"; + bool ui__dialog_yesno(const char *msg) { /* newtWinChoice should really be accepting const char pointers... */ - char yes[] = "Yes", no[] = "No"; - return newtWinChoice(NULL, yes, no, (char *)msg) == 1; + return newtWinChoice(NULL, (char *)yes, (char *)no, (char *)msg) == 1; }