Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1721897

[PATCH] perf tools: Remove BUG_ON char[] to bool implicit conversions

From David Carrillo-Cisneros <davidcc@google.com>
Newsgroups linux.kernel
Subject [PATCH] perf tools: Remove BUG_ON char[] to bool implicit conversions
Date 2017-08-28 20:40 +0200
Message-ID <ujx74-zb-19@gated-at.bofh.it> (permalink)
References <ujoGu-3Tj-29@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 <davidcc@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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/6] perf tools: Minor build fixes David Carrillo-Cisneros <davidcc@google.com> - 2017-08-27 10:00 +0200
  [PATCH 4/6] perf tools: Robustify detection of clang binary David Carrillo-Cisneros <davidcc@google.com> - 2017-08-27 10:00 +0200
    [tip:perf/core] perf tools: Robustify detection of clang binary tip-bot for David Carrillo-Cisneros <tipbot@zytor.com> - 2017-08-29 23:30 +0200
  [PATCH 3/6] tools lib: Allow external definition of CC, AR and LD David Carrillo-Cisneros <davidcc@google.com> - 2017-08-27 10:00 +0200
    [tip:perf/core] tools lib: Allow external definition of CC, AR and  LD tip-bot for David Carrillo-Cisneros <tipbot@zytor.com> - 2017-08-29 23:30 +0200
  [PATCH 2/6] perf tools: Allow external definition of flex and bison binary names David Carrillo-Cisneros <davidcc@google.com> - 2017-08-27 10:00 +0200
    [tip:perf/core] perf tools: Allow external definition of flex and  bison binary names tip-bot for David Carrillo-Cisneros <tipbot@zytor.com> - 2017-08-29 23:30 +0200
  [PATCH 1/6] tools build tests: Don't hardcode gcc name David Carrillo-Cisneros <davidcc@google.com> - 2017-08-27 10:00 +0200
    [tip:perf/core] tools build tests: Don't hardcode gcc name tip-bot for David Carrillo-Cisneros <tipbot@zytor.com> - 2017-08-29 23:30 +0200
  [PATCH 5/6] perf tools: Remove BUG_ON char[] to bool implicit conversions David Carrillo-Cisneros <davidcc@google.com> - 2017-08-27 10:00 +0200
    Re: [PATCH 5/6] perf tools: Remove BUG_ON char[] to bool implicit  conversions Jiri Olsa <jolsa@redhat.com> - 2017-08-28 11:40 +0200
      [PATCH] perf tools: Remove BUG_ON char[] to bool implicit conversions David Carrillo-Cisneros <davidcc@google.com> - 2017-08-28 20:40 +0200
  Re: [PATCH 0/6] perf tools: Minor build fixes Jiri Olsa <jolsa@redhat.com> - 2017-08-28 11:40 +0200
    Re: [PATCH 0/6] perf tools: Minor build fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-08-28 16:20 +0200
      Re: [PATCH 0/6] perf tools: Minor build fixes David Carrillo-Cisneros <davidcc@google.com> - 2017-08-28 20:40 +0200

csiph-web