Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1226860 > unrolled thread
| Started by | Peter Senna Tschudin <peter.senna@gmail.com> |
|---|---|
| First post | 2015-09-17 12:10 +0200 |
| Last post | 2015-09-18 08:00 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] tools-perf: Change -1 by false Peter Senna Tschudin <peter.senna@gmail.com> - 2015-09-17 12:10 +0200
Re: [PATCH] tools-perf: Change -1 by false Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-17 20:40 +0200
[tip:perf/urgent] perf tools: Bool functions shouldn't return -1 tip-bot for Peter Senna Tschudin <tipbot@zytor.com> - 2015-09-18 08:00 +0200
| From | Peter Senna Tschudin <peter.senna@gmail.com> |
|---|---|
| Date | 2015-09-17 12:10 +0200 |
| Subject | [PATCH] tools-perf: Change -1 by false |
| Message-ID | <q9EiE-kL-53@gated-at.bofh.it> |
Returning a negative value for a boolean function seem to have the
undesired effect of returning true. Replace -1 by false in a
bool-returning function.
The diff of the .s file before and after the change (for x86_64):
3907c3907
< movl $1, %ebx
---
> xorl %ebx, %ebx
while if -1 is replaced by true, the diff is empty.
This issue was found by the following Coccinelle semantic patch:
<smpl>
@@
identifier f;
constant C;
typedef bool;
@@
bool f (...){
<+...
* return -C;
...+>
}
</smpl>
Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
---
tools/perf/util/util.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 49a5c6a..ce465b2 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -639,7 +639,7 @@ bool find_process(const char *name)
dir = opendir(procfs__mountpoint());
if (!dir)
- return -1;
+ return false;
/* Walk through the directory. */
while (ret && (d = readdir(dir)) != NULL) {
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2015-09-17 20:40 +0200 |
| Message-ID | <q9Mga-3wR-21@gated-at.bofh.it> |
| In reply to | #1226860 |
Em Thu, Sep 17, 2015 at 12:08:53PM +0200, Peter Senna Tschudin escreveu:
> Returning a negative value for a boolean function seem to have the
> undesired effect of returning true. Replace -1 by false in a
> bool-returning function.
>
> The diff of the .s file before and after the change (for x86_64):
> 3907c3907
> < movl $1, %ebx
> ---
Please avoid adding a --- at the start of any changeset comment line, it
breaks scripts.
Thanks, applied.
- Arnaldo
> > xorl %ebx, %ebx
>
> while if -1 is replaced by true, the diff is empty.
>
> This issue was found by the following Coccinelle semantic patch:
> <smpl>
> @@
> identifier f;
> constant C;
> typedef bool;
> @@
> bool f (...){
> <+...
> * return -C;
> ...+>
> }
> </smpl>
>
> Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
> ---
> tools/perf/util/util.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
> index 49a5c6a..ce465b2 100644
> --- a/tools/perf/util/util.c
> +++ b/tools/perf/util/util.c
> @@ -639,7 +639,7 @@ bool find_process(const char *name)
>
> dir = opendir(procfs__mountpoint());
> if (!dir)
> - return -1;
> + return false;
>
> /* Walk through the directory. */
> while (ret && (d = readdir(dir)) != NULL) {
> --
> 2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Peter Senna Tschudin <tipbot@zytor.com> |
|---|---|
| Date | 2015-09-18 08:00 +0200 |
| Subject | [tip:perf/urgent] perf tools: Bool functions shouldn't return -1 |
| Message-ID | <q9WSe-27y-11@gated-at.bofh.it> |
| In reply to | #1226860 |
Commit-ID: bf6445631c6f00882b25516a174d5073ce0c6f81
Gitweb: http://git.kernel.org/tip/bf6445631c6f00882b25516a174d5073ce0c6f81
Author: Peter Senna Tschudin <peter.senna@gmail.com>
AuthorDate: Thu, 17 Sep 2015 12:08:53 +0200
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 17 Sep 2015 15:31:52 -0300
perf tools: Bool functions shouldn't return -1
Returning a negative value for a boolean function seem to have the
undesired effect of returning true. Replace -1 by false in a
bool-returning function.
The diff of the .s file before and after the change (for x86_64):
3907c3907
< movl $1, %ebx
---
> xorl %ebx, %ebx
while if -1 is replaced by true, the diff is empty.
This issue was found by the following Coccinelle semantic patch:
<smpl>
@@
identifier f;
constant C;
typedef bool;
@@
bool f (...){
<+...
* return -C;
...+>
}
</smpl>
Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Matt Fleming <matt.fleming@intel.com>
Cc: Milos Vyletel <milos@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1442484533-19742-1-git-send-email-peter.senna@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/util.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 7acafb3..c2cd9bf2 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -709,7 +709,7 @@ bool find_process(const char *name)
dir = opendir(procfs__mountpoint());
if (!dir)
- return -1;
+ return false;
/* Walk through the directory. */
while (ret && (d = readdir(dir)) != NULL) {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web