Commit 309b5185 authored by David Ahern's avatar David Ahern Committed by Arnaldo Carvalho de Melo

perf tests: Fix compile failure on do_sort_something

Commit b55ae0a9 added code-reading.c which fails to compile on Fedora 16
with compiler version:
$ gcc --version
gcc (GCC) 4.6.3 20120306 (Red Hat 4.6.3-2)

Failure message is:

tests/code-reading.c: In function ‘do_sort_something’:
tests/code-reading.c:305:13: error: stack protector not protecting local variables: variable length buffer [-Werror=stack-protector]
cc1: all warnings being treated as errors
make: *** [/tmp/junk/tests/code-reading.o] Error 1
make: *** Waiting for unfinished jobs....

v2: as Adrian noticed changed sizeof to ARRAY_SIZE
Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1376454732-83728-1-git-send-email-dsahern@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 326f59bf
...@@ -304,15 +304,14 @@ static int comp(const void *a, const void *b) ...@@ -304,15 +304,14 @@ static int comp(const void *a, const void *b)
static void do_sort_something(void) static void do_sort_something(void)
{ {
size_t sz = 40960; int buf[40960], i;
int buf[sz], i;
for (i = 0; i < (int)sz; i++) for (i = 0; i < (int)ARRAY_SIZE(buf); i++)
buf[i] = sz - i - 1; buf[i] = ARRAY_SIZE(buf) - i - 1;
qsort(buf, sz, sizeof(int), comp); qsort(buf, ARRAY_SIZE(buf), sizeof(int), comp);
for (i = 0; i < (int)sz; i++) { for (i = 0; i < (int)ARRAY_SIZE(buf); i++) {
if (buf[i] != i) { if (buf[i] != i) {
pr_debug("qsort failed\n"); pr_debug("qsort failed\n");
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment