[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180908045928.26201-1-igor.stoppa@huawei.com>
Date: Sat, 8 Sep 2018 07:59:28 +0300
From: Igor Stoppa <igor.stoppa@...il.com>
To: Arnd Bergmann <arnd@...db.de>
Cc: igor.stoppa@...il.com, Igor Stoppa <igor.stoppa@...wei.com>,
linux-arch@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH v2] asm-generic: bug: unify hints for BUG_ON()
If BUG_ON() is used instead of BUG(), it means that probably the
preferred outcome is to not BUG(), therefore the condition tested should
be unlikely().
However, when CONFIG_PROFILE_ANNOTATED_BRANCHES is enabled, the hint is
disabled, to avoid generating false-positive warnings caused by
-Wmaybe-uninitialized.
Signed-off-by: Igor Stoppa <igor.stoppa@...wei.com>
Cc: Arnd Bergmann <arnd@...db.de>
Cc: linux-arch@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
---
include/asm-generic/bug.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 20561a60db9c..b91273c36baf 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -58,8 +58,12 @@ struct bug_entry {
#endif
#ifndef HAVE_ARCH_BUG_ON
+#ifdef CONFIG_PROFILE_ANNOTATED_BRANCHES
+#define BUG_ON(condition) do { if (condition) BUG(); } while (0)
+#else
#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
#endif
+#endif
#ifdef __WARN_FLAGS
#define __WARN_TAINT(taint) __WARN_FLAGS(BUGFLAG_TAINT(taint))
@@ -183,7 +187,11 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
#endif
#ifndef HAVE_ARCH_BUG_ON
+#ifdef CONFIG_PROFILE_ANNOTATED_BRANCHES
#define BUG_ON(condition) do { if (condition) BUG(); } while (0)
+#else
+#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
+#endif
#endif
#ifndef HAVE_ARCH_WARN_ON
--
2.17.1
Powered by blists - more mailing lists