aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/include
diff options
context:
space:
mode:
authorIrina Tirdea <irina.tirdea@intel.com>2012-09-08 01:35:51 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-09-08 12:18:54 -0400
commit8bf98b89688c3d7ec071bf26d49761e38d846b47 (patch)
treeba72d4cfd34862992d9d2a1111956cc26eaae839 /tools/perf/util/include
parentef34eb4da3eb62a1511592adf7c76d74faca0b14 (diff)
perf bench: fix assert when NDEBUG is defined
When NDEBUG is defined, the assert macro will be expanded to nothing. Some assert calls used in perf are also including some functionality (e.g. system calls), not only validity checks. Therefore, if NDEBUG is defined, this functionality will be removed along with the assert. Perf also defines BUG_ON based on assert, so it has the same problem. Define BUG_ON so that the condition will be executed when NDEBUG is defined. Replace the assert statements that have these side effects with BUG_ON. For defining BUG_ON, use "if (cond) {}" insted of "if (cond) ;" because in the latter case build fails with "error: suggest braces around empty body in an ‘if’ statement [-Werror=empty-body]" Suggested-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Irina Tirdea <irina.tirdea@intel.com> Reviewed-by: Namhyung Kim <namhyung@kernel.org> Reviewed-by: Pekka Enberg <penberg@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Namhyung Kim <namhyung.kim@lge.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Steven Rostedt <rostedt@goodmis.org> Link: http://lkml.kernel.org/r/1347082551-2394-1-git-send-email-irina.tirdea@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/include')
-rw-r--r--tools/perf/util/include/linux/kernel.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/perf/util/include/linux/kernel.h b/tools/perf/util/include/linux/kernel.h
index b6842c1d02a8..4af9a10cc2d2 100644
--- a/tools/perf/util/include/linux/kernel.h
+++ b/tools/perf/util/include/linux/kernel.h
@@ -47,8 +47,12 @@
47#endif 47#endif
48 48
49#ifndef BUG_ON 49#ifndef BUG_ON
50#ifdef NDEBUG
51#define BUG_ON(cond) do { if (cond) {} } while (0)
52#else
50#define BUG_ON(cond) assert(!(cond)) 53#define BUG_ON(cond) assert(!(cond))
51#endif 54#endif
55#endif
52 56
53/* 57/*
54 * Both need more care to handle endianness 58 * Both need more care to handle endianness