All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH 01/19] common: Add a noisy assert()
Date: Sun, 29 Dec 2019 21:19:10 -0700	[thread overview]
Message-ID: <20191229211913.1.I4cda213cd69e19287b0b55dc8bca96a89e102f5a@changeid> (raw)
In-Reply-To: <20191230041928.74874-1-sjg@chromium.org>

Some U-Boot code uses BUG_ON() and WARN_ON() macros. These use __FILE__
which can include quite a large path, depending on how U-Boot is built.

The existing assert() is only checked if DEBUG is enabled. Add a new one
which is always checked, and prints a (smaller) error in that case.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/log.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/include/log.h b/include/log.h
index d8f18a6afd..c6f2f023b1 100644
--- a/include/log.h
+++ b/include/log.h
@@ -218,6 +218,20 @@ void __assert_fail(const char *assertion, const char *file, unsigned int line,
 	({ if (!(x) && _DEBUG) \
 		__assert_fail(#x, __FILE__, __LINE__, __func__); })
 
+/*
+ * This one actually gets compiled in even without DEBUG. It doesn't include the
+ * full pathname as it may be huge. Only use this when the user should be
+ * warning, similar to BUG_ON() in linux.
+ *
+ * @return true if assertion succeeded (condition is true), else false
+ */
+#define assert_noisy(x) \
+	({ bool _val = (x); \
+	if (!_val) \
+		__assert_fail(#x, "?", __LINE__, __func__); \
+	_val; \
+	})
+
 #if CONFIG_IS_ENABLED(LOG) && defined(CONFIG_LOG_ERROR_RETURN)
 /*
  * Log an error return value, possibly with a message. Usage:
-- 
2.24.1.735.g03f4e72817-goog

  reply	other threads:[~2019-12-30  4:19 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-30  4:19 [PATCH 00/19] dm: core: Fully separate ofdata_to_platdata() from probe() Simon Glass
2019-12-30  4:19 ` Simon Glass [this message]
2019-12-30  4:19 ` [PATCH 02/19] dm: core: Use assert_noisy() in devres Simon Glass
2019-12-30  4:19 ` [PATCH 03/19] usb: Drop use of BUG_ON() and WARN_ON() Simon Glass
2019-12-30  4:19 ` [PATCH 04/19] x86: apl: Avoid accessing the PCI bus before it is probed Simon Glass
2019-12-30  4:19 ` [PATCH 05/19] pci: Print a warning if the bus is accessed before probing Simon Glass
2019-12-30  4:19 ` [PATCH 06/19] aspeed: ast2500: Read clock ofdata in the correct method Simon Glass
2020-01-07  8:20   ` Cédric Le Goater
2020-01-09 20:04     ` Simon Glass
2020-01-10  8:57     ` sjg at google.com
2019-12-30  4:19 ` [PATCH 07/19] dm: core: Don't clear active flag twice when probe() fails Simon Glass
2019-12-30  4:19 ` [PATCH 08/19] dm: core: Move ofdata_to_platdata() call earlier Simon Glass
2019-12-30  4:19 ` [PATCH 09/19] dm: core: Allocate parent data separate from probing parent Simon Glass
2019-12-30  4:19 ` [PATCH 10/19] dm: core: Add a comment for DM_FLAG_OF_PLATDATA Simon Glass
2019-12-30  4:19 ` [PATCH 11/19] dm: core: Export a new function to read platdata Simon Glass
2019-12-30  4:19 ` [PATCH 12/19] dm: core: Add a new flag to track platform data Simon Glass
2019-12-30  4:19 ` [PATCH 13/19] dm: devres: Create a new devres header file Simon Glass
2019-12-30  4:19 ` [PATCH 14/19] test: Add functions to find the amount of allocated memory Simon Glass
2019-12-30  4:19 ` [PATCH 15/19] dm: devres: Convert to use logging Simon Glass
2019-12-30  4:19 ` [PATCH 16/19] dm: test: Add a test driver for devres Simon Glass
2019-12-30  4:19 ` [PATCH 17/19] dm: devres: Add tests Simon Glass
2019-12-30  4:19 ` [PATCH 18/19] dm: devres: Use an enum for the allocation phase Simon Glass
2019-12-30  4:19 ` [PATCH 19/19] dm: devres: Add a new OFDATA phase Simon Glass
2020-01-10  8:57 ` [PATCH 18/19] dm: devres: Use an enum for the allocation phase sjg at google.com
2020-01-10  8:57 ` [PATCH 19/19] dm: devres: Add a new OFDATA phase sjg at google.com
2020-01-10  8:57 ` [PATCH 17/19] dm: devres: Add tests sjg at google.com
2020-01-10  8:57 ` [PATCH 16/19] dm: test: Add a test driver for devres sjg at google.com
2020-01-10  8:57 ` [PATCH 14/19] test: Add functions to find the amount of allocated memory sjg at google.com
2020-01-10  8:57 ` [PATCH 15/19] dm: devres: Convert to use logging sjg at google.com
2020-01-10  8:57 ` [PATCH 13/19] dm: devres: Create a new devres header file sjg at google.com
2020-01-10  8:57 ` [PATCH 12/19] dm: core: Add a new flag to track platform data sjg at google.com
2020-01-10  8:57 ` [PATCH 11/19] dm: core: Export a new function to read platdata sjg at google.com
2020-01-10  8:57 ` [PATCH 10/19] dm: core: Add a comment for DM_FLAG_OF_PLATDATA sjg at google.com
2020-01-10  8:57 ` [PATCH 09/19] dm: core: Allocate parent data separate from probing parent sjg at google.com
2020-01-10  8:57 ` [PATCH 08/19] dm: core: Move ofdata_to_platdata() call earlier sjg at google.com
2020-01-10  8:57 ` [PATCH 07/19] dm: core: Don't clear active flag twice when probe() fails sjg at google.com
2020-01-10  8:57 ` [PATCH 05/19] pci: Print a warning if the bus is accessed before probing sjg at google.com
2020-01-10  8:57 ` [PATCH 04/19] x86: apl: Avoid accessing the PCI bus before it is probed sjg at google.com
2020-01-10  8:57 ` [PATCH 03/19] usb: Drop use of BUG_ON() and WARN_ON() sjg at google.com
2020-01-10  8:57 ` [PATCH 02/19] dm: core: Use assert_noisy() in devres sjg at google.com
2020-01-10  8:57 ` [PATCH 01/19] common: Add a noisy assert() sjg at google.com

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=20191229211913.1.I4cda213cd69e19287b0b55dc8bca96a89e102f5a@changeid \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.