From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lothar =?UTF-8?B?V2HDn21hbm4=?= Date: Tue, 12 Dec 2017 10:06:19 +0100 Subject: [U-Boot] [PATCH v2 3/5] Introduce CONFIG_ENABLE_BUG_CHECKS to disable BUG{_ON} by default In-Reply-To: <1512358624-6309-4-git-send-email-yamada.masahiro@socionext.com> References: <1512358624-6309-1-git-send-email-yamada.masahiro@socionext.com> <1512358624-6309-4-git-send-email-yamada.masahiro@socionext.com> Message-ID: <20171212100619.16579688@karo-electronics.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de Hi, On Mon, 4 Dec 2017 12:37:02 +0900 Masahiro Yamada wrote: > BUG() and BUG_ON() are generally used to test a condition that should > never happen. If it does, it is a bug. >=20 > Linux always enables them, but doing so in U-Boot causes image size > problems on some platforms. Introduce CONFIG_ENABLE_BUG_CHECKS to > make them no-op by default. Platforms without image size constraint > are free to enable this option to catch bugs easily. >=20 > Likewise, silence WARN_ON() unless this option is enabled. >=20 > Suggested-by: Tom Rini > Signed-off-by: Masahiro Yamada > --- >=20 > Changes in v2: > - Newly added >=20 > include/linux/bug.h | 9 ++++++++- > lib/Kconfig | 7 +++++++ > 2 files changed, 15 insertions(+), 1 deletion(-) >=20 > diff --git a/include/linux/bug.h b/include/linux/bug.h > index f07bb71..ac1c7de 100644 > --- a/include/linux/bug.h > +++ b/include/linux/bug.h > @@ -6,17 +6,24 @@ > #include > #include > =20 > +#ifdef CONFIG_ENABLE_BUG_CHECKS > #define BUG() do { \ > printk("BUG at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \ > panic("BUG!"); \ > } while (0) > +#define __WARN() \ > + printk("WARNING at %s:%d/%s()!\n", __FILE__, __LINE__, __func__) > +#else > +#define BUG() > +#define __WARN() > +#endif > =20 > #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (= 0) > =20 > #define WARN_ON(condition) ({ \ > int __ret_warn_on =3D !!(condition); \ > if (unlikely(__ret_warn_on)) \ > - printk("WARNING at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \ > + __WARN(); \ > unlikely(__ret_warn_on); \ > }) > =20 > diff --git a/lib/Kconfig b/lib/Kconfig > index 00ac650..36b1b3b 100644 > --- a/lib/Kconfig > +++ b/lib/Kconfig > @@ -45,6 +45,13 @@ config USE_TINY_PRINTF > =20 > The supported format specifiers are %c, %s, %u/%d and %x. > =20 > +config ENABLE_BUG_CHECKS > + bool "Enable BUG/BUG_ON() checks and WARN_ON() logs" > + help This should be 'default y' IMO to keep the current behaviour for all existing platforms. Lothar Wa=C3=9Fmann