From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759763Ab2IHBYY (ORCPT ); Fri, 7 Sep 2012 21:24:24 -0400 Received: from mail-ob0-f174.google.com ([209.85.214.174]:61367 "EHLO mail-ob0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758667Ab2IHBYX (ORCPT ); Fri, 7 Sep 2012 21:24:23 -0400 MIME-Version: 1.0 In-Reply-To: <1346842839.2461.13.camel@laptop> References: <1346842839.2461.13.camel@laptop> From: Irina Tirdea Date: Sat, 8 Sep 2012 04:24:02 +0300 Message-ID: Subject: Re: [PATCH] perf bench: fix assert when NDEBUG is defined To: Peter Zijlstra Cc: Steven Rostedt , Arnaldo Carvalho de Melo , Ingo Molnar , LKML , Namhyung Kim , Frederic Weisbecker Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 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 indeed the right fix. I will use this approach, test it and resubmit. Thanks, Irina