diff options
author | Simon Glass <sjg@chromium.org> | 2019-12-29 21:19:10 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2020-01-07 16:02:38 -0700 |
commit | cd01d2d595bae3db60a0b222912ea875dd0687c8 (patch) | |
tree | 2a3d8bd57ffb38fe0c015ab0b86e758fab00e25c /include/log.h | |
parent | d8a3f5259a36e76d1de127f65714c40918e8ee4c (diff) |
common: Add a noisy assert()
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>
Diffstat (limited to 'include/log.h')
-rw-r--r-- | include/log.h | 14 |
1 files changed, 14 insertions, 0 deletions
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: |