mirror of
https://xff.cz/git/u-boot/
synced 2025-09-02 09:12:08 +02:00
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>
This commit is contained in:
@@ -218,6 +218,20 @@ void __assert_fail(const char *assertion, const char *file, unsigned int line,
|
|||||||
({ if (!(x) && _DEBUG) \
|
({ if (!(x) && _DEBUG) \
|
||||||
__assert_fail(#x, __FILE__, __LINE__, __func__); })
|
__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)
|
#if CONFIG_IS_ENABLED(LOG) && defined(CONFIG_LOG_ERROR_RETURN)
|
||||||
/*
|
/*
|
||||||
* Log an error return value, possibly with a message. Usage:
|
* Log an error return value, possibly with a message. Usage:
|
||||||
|
Reference in New Issue
Block a user