Skip to contentSkip to conversation

perf tests: Fix compile failure on do_sort_something - v2

PATCH Applied David Ahern 4 participants 4 messages Aug 14, 2013 – Aug 15, 2013 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf tests: Fix compile failure on do_sort_something - v2

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

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 +5 -6
index eec1421..df9afd9 100644
@@ -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)ARRAY_SIZE(buf); i++)
+		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) {
 			pr_debug("qsort failed\n");
 			break;
Signature · 1 line
1.7.10.1
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines · David Ahern

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....

Quoted 5 lines

v2: as Adrian noticed changed sizeof to ARRAY_SIZE

Cc Adrian Hunter <[email protected]>
Cc Jiri Olsa <[email protected]>
Quoted 30 lines
---
 tools/perf/tests/code-reading.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
tools/perf/tests/code-reading.c +5 -6
index eec1421..df9afd9 100644
@@ -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)ARRAY_SIZE(buf); i++)
+		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) {
 			pr_debug("qsort failed\n");
 			break;
#3 lore raw

[tip:perf/core] perf tests: Fix compile failure on do_sort_something

In reply to David Ahern
perf tests: Fix compile failure on do_sort_something
Commit-ID:  309b5185047c5309bbc576025f6c5e257edd9f69
Gitweb:     http://git.kernel.org/tip/309b5185047c5309bbc576025f6c5e257edd9f69
Author:     David Ahern <[email protected]>
AuthorDate: Tue, 13 Aug 2013 22:32:12 -0600
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 14 Aug 2013 11:42:45 -0300

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

---
 tools/perf/tests/code-reading.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
tools/perf/tests/code-reading.c +5 -6
index eec1421..df9afd9 100644
@@ -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)ARRAY_SIZE(buf); i++)
+		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) {
 			pr_debug("qsort failed\n");
 			break;