From patchwork Mon Dec 4 03:37:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 120486 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3946870qgn; Sun, 3 Dec 2017 19:38:09 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ39W0k1+V37hBlu+tm+4CZvBVm4nZYsfC4H5b/QSBesDKGywW4HDTD5b5WUeD3W7M58itf X-Received: by 10.80.170.24 with SMTP id o24mr29440002edc.40.1512358689217; Sun, 03 Dec 2017 19:38:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512358689; cv=none; d=google.com; s=arc-20160816; b=SJOKZEVWabMfeVRG16QU/nyVBX0RSSmWGvdXg+kKxr/3Hm2wMGVIySBhayI+PplEpK qRH1z2hUL7fdm5Hn4oNT7zsk5iF984sCnLqLdc+zIQosumDeDaSTqEuESozaDrVp9YII y2mUETneHIHCnr35HPmXwxXEvN2Z4lD86UWwLxwQRCIoz0IqFc/Nhs2EFe3RVEPBEJq/ +MIeJ/QNTisQ8KripmoWuRaub8+RZv9YqVNOUhS9Y2rasK91inZofTPXU2GbCZ4qozhJ vnsORZkKryG7yInm+ku0Dpm4JUYIKCGvcD2SypDXah9hv36wzVcu7Wf8fc8Gdz84RunK SQmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=UwL0V/ZCfceDMgGoM4jv3AjruqIxJoDnSb9NKubRYIQ=; b=rBQY8n3snl9MDVBtxePrBgfcVR9oZwInwTW6+d9gxeUqLiSeA42Q6TWJmbYUicqt8l dCA+YTC53sj+mSwI5WK6aagrwnX+iaWLbYysUQQxWaIpcDo//stNvw9nk7n8ydW1telb qysE8BjsuHlTI9cDWGBcnGoQQ6Di7MVWd44GC4m4/5g15rBMPvNCOHfxrCzeKuhrmPNM it45LCZrDhHWDPOITwEv8uI+NDewNY5+XZQTJHdnbXtfUAaD1Ke0+SKGo/sBZrsehnIh 9ozYX8Wiq9liO6Oiip8SRAYYuNHG8vG4iOiZafrrlUiwwh+3hGwNe56fNb4t16/ae74P adXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=g3dU2ize; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id c14si2144591edj.440.2017.12.03.19.38.08; Sun, 03 Dec 2017 19:38:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=g3dU2ize; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 48CE1C22033; Mon, 4 Dec 2017 03:38:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 1BC9FC21FA6; Mon, 4 Dec 2017 03:38:01 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4ECF2C22017; Mon, 4 Dec 2017 03:37:59 +0000 (UTC) Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) by lists.denx.de (Postfix) with ESMTPS id 679C1C21FA6 for ; Mon, 4 Dec 2017 03:37:58 +0000 (UTC) Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id vB43bE4r022247; Mon, 4 Dec 2017 12:37:19 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com vB43bE4r022247 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1512358639; bh=Gi/ht9c3fyn/8Akvk6mMZQPpPxMdcH+IhacxlC4Sspg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g3dU2izeC7EujLUktrf99jF56OzacXVICNvbiJ1sbKayd7lmz8dHJMtP/l9YV2/Cm aeNpBRmRXAh3GThefI1gL06yVcEgi+NgLbS09oTFbplWZ72YdFjdNWNNxd5UcH4isv T4kw7XF9Wbriv2FFJzOmR6CWjwaRPeqMtZ9FB9VyRpGoTJztn8lGu3A9r1pHETHb8+ aUlOZxuML29qzGDfVqvpFPloRLcKmaCK4GQ08AxWuhg7vi9Lm4VQslmoTr3Jj9RSwT DOmSW6tCzQGMMVSwN3Cdf0CsZbVHZHQdQWvE0wgP4QS13Lb3TNrwyeC/tFC8K3IMlB PizUmc8XOO6XQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Mon, 4 Dec 2017 12:37:02 +0900 Message-Id: <1512358624-6309-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512358624-6309-1-git-send-email-yamada.masahiro@socionext.com> References: <1512358624-6309-1-git-send-email-yamada.masahiro@socionext.com> Cc: Marek Vasut , Tom Rini Subject: [U-Boot] [PATCH v2 3/5] Introduce CONFIG_ENABLE_BUG_CHECKS to disable BUG{_ON} by default X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" BUG() and BUG_ON() are generally used to test a condition that should never happen. If it does, it is a bug. 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. Likewise, silence WARN_ON() unless this option is enabled. Suggested-by: Tom Rini Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass --- Changes in v2: - Newly added include/linux/bug.h | 9 ++++++++- lib/Kconfig | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) 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 +#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 #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0) #define WARN_ON(condition) ({ \ int __ret_warn_on = !!(condition); \ if (unlikely(__ret_warn_on)) \ - printk("WARNING at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \ + __WARN(); \ unlikely(__ret_warn_on); \ }) 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 The supported format specifiers are %c, %s, %u/%d and %x. +config ENABLE_BUG_CHECKS + bool "Enable BUG/BUG_ON() checks and WARN_ON() logs" + help + BUG() and BUG_ON() are no-op by default. This option enables + them to print noisy messages, then reboot or halt the system. + It also enables WARN_ON() messages. + config PANIC_HANG bool "Do not reset the system on fatal error" help