Re: [PATCH] perf bench: fix assert when NDEBUG is defined

2012-09-07 Thread Irina Tirdea
> Its valid (although admittedly dubious) to have BUG_ON with > side-effects. > > The 'right' fix would be something like: > > --- > #ifndef BUG_ON > +#ifdef NDEBUG > +#define BUG_ON(cond) do { if (cond) ; } while (0) > +#else > #define BUG_ON(cond) assert(!(cond)) > #endif > +#endif > This is

Re: [PATCH] perf bench: fix assert when NDEBUG is defined

2012-09-05 Thread Peter Zijlstra
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: --- t

Re: [PATCH] perf bench: fix assert when NDEBUG is defined

2012-09-02 Thread Pekka Enberg
On Mon, Sep 3, 2012 at 4:45 AM, Namhyung Kim wrote: > On Mon, 3 Sep 2012 03:04:32 +0300, Irina Tirdea wrote: >> From: Irina Tirdea >> >> 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 ca

Re: [PATCH] perf bench: fix assert when NDEBUG is defined

2012-09-02 Thread Namhyung Kim
On Mon, 3 Sep 2012 03:04:32 +0300, Irina Tirdea wrote: > From: Irina Tirdea > > 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 > de

[PATCH] perf bench: fix assert when NDEBUG is defined

2012-09-02 Thread Irina Tirdea
From: Irina Tirdea 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, these functionality will be removed along with the assert.