perf tests: Fix compile failure on do_sort_something
PATCH 1/1 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....
--- tools/perf/tests/code-reading.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
tools/perf/tests/code-reading.c +5 -6
@@ -304,15 +304,14 @@ static int comp(const void *a, const void *b)static void do_sort_something (void ) { -size_t sz =40960 ; -int buf[sz], i; +int buf[40960 ], i; -for (i =0 ; i < (int )sz; i++) - buf[i] = sz - i -1 ; +for (i =0 ; i < (int )sizeof (buf); i++) + buf[i] =sizeof (buf) - i -1 ; -qsort (buf, sz,sizeof (int ), comp); +qsort (buf,sizeof (buf),sizeof (int ), comp); -for (i =0 ; i < (int )sz; i++) { +for (i =0 ; i < (int )sizeof (buf); i++) {if (buf[i] != i) {pr_debug ("qsort failed\n" );break ;
Signature · 1 line
1.7.10.1
Adrian Hunter
reviewerQuoted 25 lines · David Ahern
Commit
b55ae0a9addedcode-reading.cwhich 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....Signed-off-by David Ahern <[email protected]>Cc Adrian Hunter <[email protected]>Cc Jiri Olsa <[email protected]>--- tools/perf/tests/code-reading.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)tools/perf/tests/code-reading.c +0
-0
tools/perf/tests/code-reading.c static int comp(const void *a, const void *b) · line 309
Quoted 10 lines
tools/perf/tests/code-reading.c +2
-4@@ -304,15 +304,14 @@ static int comp(const void *a, const void *b)static void do_sort_something (void ) { -size_t sz =40960 ; -int buf[sz], i; +int buf[40960 ], i; -for (i =0 ; i < (int )sz; i++) - buf[i] = sz - i -1 ; +for (i =0 ; i < (int )sizeof (buf); i++)
Should that be ARRAY_SIZE not sizeof
Quoted 11 lines
tools/perf/tests/code-reading.c +3
-2+ buf[i] =sizeof (buf) - i -1 ; -qsort (buf, sz,sizeof (int ), comp); +qsort (buf,sizeof (buf),sizeof (int ), comp); -for (i =0 ; i < (int )sz; i++) { +for (i =0 ; i < (int )sizeof (buf); i++) {if (buf[i] != i) {pr_debug ("qsort failed\n" );break ;
Quoted 33 lines · Adrian Hunter
Quoted 32 lines · David Ahern
Commit
b55ae0a9addedcode-reading.cwhich 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....Signed-off-by David Ahern <[email protected]>Cc Adrian Hunter <[email protected]>Cc Jiri Olsa <[email protected]>--- tools/perf/tests/code-reading.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)tools/perf/tests/code-reading.c +1
-2@@ -304,15 +304,14 @@ static int comp(const void *a, const void *b)static void do_sort_something (void ) { -size_t sz =40960 ; -int buf[sz], i; +int buf[40960 ], i;
Quoted 6 lines
tools/perf/tests/code-reading.c static int comp(const void *a, const void *b) · line 309
Quoted 3 lines
tools/perf/tests/code-reading.c +1
-2-for (i =0 ; i < (int )sz; i++) - buf[i] = sz - i -1 ; +for (i =0 ; i < (int )sizeof (buf); i++)Should that be
ARRAY_SIZEnot sizeof
oops, yes it should.
David