Skip to contentSkip to conversation

perf tests: evsel-tp-sched: Fix bitwise operator

PATCH In review Gustavo A. R. Silva 4 participants 6 messages Jan 22, 2019 – Feb 9, 2019 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf tests: evsel-tp-sched: Fix bitwise operator

Notice that the use of the bitwise OR operator '|' always leads to true in this particular case, which seems a bit suspicious due to the context in which this expression is being used.

Fix this by using bitwise AND operator '&' instead.

This bug was detected with the help of Coccinelle.

Fixes 6a6cd11d4e57 ("perf test: Add test for the sched tracepoint format fields")

---

NOTE: Notice that this code has been there since 2012. So, it would
be helpful if someone can double-check this. Thanks.

 tools/perf/tests/evsel-tp-sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/evsel-tp-sched.c +1 -1
index 5f8501c68da4..5cbba70bcdd0 100644
@@ -17,7 +17,7 @@ static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name,
 		return -1;
 	}
 
-	is_signed = !!(field->flags | TEP_FIELD_IS_SIGNED);
+	is_signed = !!(field->flags & TEP_FIELD_IS_SIGNED);
 	if (should_be_signed && !is_signed) {
 		pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n",
 			 evsel->name, name, is_signed, should_be_signed);
Signature · 1 line
2.20.1
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Gustavo A. R. Silva

Notice that the use of the bitwise OR operator '|' always leads to true in this particular case, which seems a bit suspicious due to the context in which this expression is being used.

Fix this by using bitwise AND operator '&' instead.

This bug was detected with the help of Coccinelle.

Fixes 6a6cd11d4e57 ("perf test: Add test for the sched tracepoint format fields")

nice catch

thanks,
jirka

Quoted 24 lines

---

NOTE: Notice that this code has been there since 2012. So, it would
be helpful if someone can double-check this. Thanks.

 tools/perf/tests/evsel-tp-sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/evsel-tp-sched.c +1 -1
index 5f8501c68da4..5cbba70bcdd0 100644
@@ -17,7 +17,7 @@ static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name,
 		return -1;
 	}
 
-	is_signed = !!(field->flags | TEP_FIELD_IS_SIGNED);
+	is_signed = !!(field->flags & TEP_FIELD_IS_SIGNED);
 	if (should_be_signed && !is_signed) {
 		pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n",
 			 evsel->name, name, is_signed, should_be_signed);
Signature · 1 line
2.20.1
#2 lore raw
Quoted 7 lines · Jiri Olsa
Quoted 6 lines · Gustavo A. R. Silva

Notice that the use of the bitwise OR operator '|' always leads to true in this particular case, which seems a bit suspicious due to the context in which this expression is being used.

Fix this by using bitwise AND operator '&' instead.

Quoted 8 lines
Quoted 5 lines

This bug was detected with the help of Coccinelle.

Fixes 6a6cd11d4e57 ("perf test: Add test for the sched tracepoint format fields")

nice catch

Glad to help. :)

Quoted 2 lines

Thanks
--
Gustavo

Quoted 28 lines

thanks,
jirka

Quoted 24 lines

---

NOTE: Notice that this code has been there since 2012. So, it would
be helpful if someone can double-check this. Thanks.

 tools/perf/tests/evsel-tp-sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/evsel-tp-sched.c +1 -1
index 5f8501c68da4..5cbba70bcdd0 100644
@@ -17,7 +17,7 @@ static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name,
 		return -1;
 	}
 
-	is_signed = !!(field->flags | TEP_FIELD_IS_SIGNED);
+	is_signed = !!(field->flags & TEP_FIELD_IS_SIGNED);
 	if (should_be_signed && !is_signed) {
 		pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n",
 			 evsel->name, name, is_signed, should_be_signed);
Signature · 1 line
2.20.1
#3 lore raw

Hi all,

Friendly ping:

Who can take this?

Thanks
--
Gustavo

Quoted 56 lines · Gustavo A. R. Silva
Quoted 7 lines · Jiri Olsa
Quoted 6 lines · Gustavo A. R. Silva

Notice that the use of the bitwise OR operator '|' always leads to true in this particular case, which seems a bit suspicious due to the context in which this expression is being used.

Fix this by using bitwise AND operator '&' instead.

Quoted 8 lines
Quoted 5 lines

This bug was detected with the help of Coccinelle.

Fixes 6a6cd11d4e57 ("perf test: Add test for the sched tracepoint format fields")

nice catch

Glad to help. :)

Quoted 2 lines

Thanks
--
Gustavo

Quoted 28 lines

thanks,
jirka

Quoted 24 lines

---

NOTE: Notice that this code has been there since 2012. So, it would
be helpful if someone can double-check this. Thanks.

 tools/perf/tests/evsel-tp-sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/evsel-tp-sched.c +1 -1
index 5f8501c68da4..5cbba70bcdd0 100644
@@ -17,7 +17,7 @@ static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name,
 		return -1;
 	}
 
-	is_signed = !!(field->flags | TEP_FIELD_IS_SIGNED);
+	is_signed = !!(field->flags & TEP_FIELD_IS_SIGNED);
 	if (should_be_signed && !is_signed) {
 		pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n",
 			 evsel->name, name, is_signed, should_be_signed);
Signature · 1 line
2.20.1
#4 lore raw
In reply to Jiri Olsa

Em Wed, Jan 23, 2019 at 09:33:38AM +0100, Jiri Olsa escreveu:

Quoted 9 lines · Gustavo A. R. Silva
Quoted 8 lines

Notice that the use of the bitwise OR operator '|' always leads to true in this particular case, which seems a bit suspicious due to the context in which this expression is being used.

Fix this by using bitwise AND operator '&' instead.

This bug was detected with the help of Coccinelle.

Quoted 7 lines
Quoted 3 lines
Fixes 6a6cd11d4e57 ("perf test: Add test for the sched tracepoint format fields")

nice catch

Argh, applied, and looking for an old brown paper bag...

- Arnaldo

#5 lore raw

[tip:perf/urgent] perf tests evsel-tp-sched: Fix bitwise operator

In reply to Gustavo A. R. Silva
perf tests evsel-tp-sched: Fix bitwise operator
Commit-ID:  489338a717a0dfbbd5a3fabccf172b78f0ac9015
Gitweb:     https://git.kernel.org/tip/489338a717a0dfbbd5a3fabccf172b78f0ac9015
Author:     Gustavo A. R. Silva <[email protected]>
AuthorDate: Tue, 22 Jan 2019 17:34:39 -0600
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 4 Feb 2019 11:32:14 -0300

perf tests evsel-tp-sched: Fix bitwise operator

Notice that the use of the bitwise OR operator '|' always leads to true in this particular case, which seems a bit suspicious due to the context in which this expression is being used.

Fix this by using bitwise AND operator '&' instead.

This bug was detected with the help of Coccinelle.

Cc Alexander Shishkin <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Fixes 6a6cd11d4e57 ("perf test: Add test for the sched tracepoint format fields")
---
 tools/perf/tests/evsel-tp-sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/evsel-tp-sched.c +1 -1
index 5f8501c68da4..5cbba70bcdd0 100644
@@ -17,7 +17,7 @@ static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name,
 		return -1;
 	}
 
-	is_signed = !!(field->flags | TEP_FIELD_IS_SIGNED);
+	is_signed = !!(field->flags & TEP_FIELD_IS_SIGNED);
 	if (should_be_signed && !is_signed) {
 		pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n",
 			 evsel->name, name, is_signed, should_be_signed);