Messages in this thread Patch in this message | | | Subject | Re: [PATCH] perf bench: fix assert when NDEBUG is defined | From | Peter Zijlstra <> | Date | Wed, 05 Sep 2012 13:00:39 +0200 |
| |
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
| |