From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Irina Tirdea <irina.tirdea@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [PATCH] perf bench: fix assert when NDEBUG is defined
Date: Wed, 05 Sep 2012 13:00:39 +0200 [thread overview]
Message-ID: <1346842839.2461.13.camel@laptop> (raw)
In-Reply-To: <CANg8OWLL6gzUpZuq8YT2bSbT5=EVWejbpCX0TM8dt7mKXyZ9Yg@mail.gmail.com>
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
next prev parent reply other threads:[~2012-09-05 11:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-03 0:04 [PATCH] perf bench: fix assert when NDEBUG is defined Irina Tirdea
2012-09-03 1:45 ` Namhyung Kim
2012-09-03 5:21 ` Pekka Enberg
2012-09-05 11:00 ` Peter Zijlstra [this message]
2012-09-08 1:24 ` Irina Tirdea
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1346842839.2461.13.camel@laptop \
--to=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=fweisbec@gmail.com \
--cc=irina.tirdea@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).