When compiling with LLVM, errors like this are shown:

  builtin-lock.c:46:10: error: implicit conversion turns string literal into 
bool: 'const char [39]' to 'bool'

due to error message implicit conversion into bool. Fix it printing
the error message and returning an error when possible.

Signed-off-by: David Carrillo-Cisneros <davi...@google.com>
---
 tools/perf/builtin-lock.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index ff98652484a7..55d3997ce194 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -3,6 +3,7 @@
 #include "builtin.h"
 #include "perf.h"
 
+#include "asm/bug.h"
 #include "util/evlist.h"
 #include "util/evsel.h"
 #include "util/util.h"
@@ -147,12 +148,11 @@ static void thread_stat_insert(struct thread_stat *new)
                p = container_of(*rb, struct thread_stat, rb);
                parent = *rb;
 
+               WARN(new->tid == p->tid, "inserting invalid thread_stat\n");
                if (new->tid < p->tid)
                        rb = &(*rb)->rb_left;
-               else if (new->tid > p->tid)
-                       rb = &(*rb)->rb_right;
                else
-                       BUG_ON("inserting invalid thread_stat\n");
+                       rb = &(*rb)->rb_right;
        }
 
        rb_link_node(&new->rb, parent, rb);
@@ -457,8 +457,8 @@ static int report_lock_acquire_event(struct perf_evsel 
*evsel,
                free(seq);
                goto end;
        default:
-               BUG_ON("Unknown state of lock sequence found!\n");
-               break;
+               pr_err("Unknown state of lock sequence found!\n");
+               return -1;
        }
 
        ls->nr_acquire++;
@@ -518,8 +518,8 @@ static int report_lock_acquired_event(struct perf_evsel 
*evsel,
                free(seq);
                goto end;
        default:
-               BUG_ON("Unknown state of lock sequence found!\n");
-               break;
+               pr_err("Unknown state of lock sequence found!\n");
+               return -1;
        }
 
        seq->state = SEQ_STATE_ACQUIRED;
@@ -573,8 +573,8 @@ static int report_lock_contended_event(struct perf_evsel 
*evsel,
                free(seq);
                goto end;
        default:
-               BUG_ON("Unknown state of lock sequence found!\n");
-               break;
+               pr_err("Unknown state of lock sequence found!\n");
+               return -1;
        }
 
        seq->state = SEQ_STATE_CONTENDED;
@@ -632,8 +632,8 @@ static int report_lock_release_event(struct perf_evsel 
*evsel,
                bad_hist[BROKEN_RELEASE]++;
                goto free_seq;
        default:
-               BUG_ON("Unknown state of lock sequence found!\n");
-               break;
+               pr_err("Unknown state of lock sequence found!\n");
+               return -1;
        }
 
        ls->nr_release++;
-- 
2.14.1.342.g6490525c54-goog

Reply via email to