Skip to content

Commit

Permalink
perf, ui: Eliminate stack-smashing protection compiler complaint
Browse files Browse the repository at this point in the history
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 <gorcunov@openvz.org>
Acked-by: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <20101106084724.GA5956@lenovo>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Cyrill Gorcunov authored and Ingo Molnar committed Nov 10, 2010
1 parent f6614b7 commit a3da8e4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tools/perf/util/ui/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ int ui__help_window(const char *text)
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;
}

0 comments on commit a3da8e4

Please sign in to comment.