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

From: Namhyung Kim
Date: Sat Sep 08 2012 - 10:12:13 EST

On Sat, 8 Sep 2012 08:35:51 +0300, Irina Tirdea wrote:
> From: Irina Tirdea <irina.tirdea@xxxxxxxxx>
> 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@xxxxxxxxx>
> Signed-off-by: Irina Tirdea <irina.tirdea@xxxxxxxxx>

Reviewed-by: Namhyung Kim <namhyung@xxxxxxxxxx>

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at