perf tools: Bool functions shouldn't return -1
authorPeter Senna Tschudin <peter.senna@gmail.com>
Thu, 17 Sep 2015 10:08:53 +0000 (12:08 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 17 Sep 2015 18:31:52 +0000 (15:31 -0300)
commitbf6445631c6f00882b25516a174d5073ce0c6f81
tree8a1538b1c9f1e00761c71a1d3989e53de796c8cf
parentb0063dbfb031a7c728ed0d9533257e8329292cf1
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