Skip to contentSkip to conversation

perf compilation fails on Ubuntu's gcc 4.3.3

PATCH Cyrill Gorcunov 1 participant 1 message Aug 21, 2010 perf events

lore
Share & tools
lore
#0 lore raw

Hi,

here is what I got today trying to compile perf on my Ubuntu system

Quoted 5 lines

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

An ugly hack like

tools/perf/util/ui/util.c +3 -2
index 9706d9d..4ef6a86 100644
@@ -107,6 +107,7 @@ out_destroy_form:
 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;
+       const char *yes = "Yes";
+       const char *no = "No";
+       return newtWinChoice(NULL, (char *)yes, (char *)no, (char *)msg) == 1;
 }

did trick for me. But the issue origin is

EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstack-protector

What is the best way to deal with it?

 | cyrill@lenovo perf $ gcc --version
 | gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3
 | Copyright (C) 2008 Free Software Foundation, Inc.
 | This is free software; see the source for copying conditions.  There is NO
 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

-- Cyrill