lkml.org 
[lkml]   [2012]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] perf bench: fix assert when NDEBUG is defined
From
Date
On Mon, 2012-09-03 at 03:04 +0300, Irina Tirdea wrote:
> - BUG_ON(gettimeofday(&tv_start, NULL));
> + ret = gettimeofday(&tv_start, NULL);
> + BUG_ON(ret);

Its valid (although admittedly dubious) to have BUG_ON with
side-effects.

The 'right' fix would be something like:

---
tools/perf/util/include/linux/kernel.h | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/tools/perf/util/include/linux/kernel.h b/tools/perf/util/include/linux/kernel.h
index b6842c1..a5efd924 100644
--- a/tools/perf/util/include/linux/kernel.h
+++ b/tools/perf/util/include/linux/kernel.h
@@ -47,8 +47,12 @@
#endif

#ifndef BUG_ON
+#ifdef NDEBUG
+#define BUG_ON(cond) do { if (cond) ; } while (0)
+#else
#define BUG_ON(cond) assert(!(cond))
#endif
+#endif

/*
* Both need more care to handle endianness



\
 
 \ /
  Last update: 2012-09-05 15:42    [W:0.061 / U:0.144 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site