assert: Add option to disable condition from assertion message
Add Kconfig option to disable the conditional expression in the assert that failed. This would save code space, and file and line provides better information than the conditional expression in case where the same expression would be asserted upon. For example __ASSERT_NO_MSG(buf) wouldn't make much sense in configuration where CONFIG_ASSERT_NO_FILE_INFO was enabled. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
9483e432d8
commit
94d331b2eb
2 changed files with 16 additions and 1 deletions
|
@ -26,6 +26,12 @@
|
|||
#define __ASSERT_FILE_INFO __FILE__
|
||||
#endif /* CONFIG_ASSERT_NO_FILE_INFO */
|
||||
|
||||
#ifdef CONFIG_ASSERT_NO_COND_INFO
|
||||
#define __ASSERT_COND_INFO(test) ""
|
||||
#else /* CONFIG_ASSERT_NO_COND_INFO */
|
||||
#define __ASSERT_COND_INFO(test) Z_STRINGIFY(test)
|
||||
#endif /* CONFIG_ASSERT_NO_COND_INFO */
|
||||
|
||||
#ifdef __ASSERT_ON
|
||||
#if (__ASSERT_ON < 0) || (__ASSERT_ON > 2)
|
||||
#error "Invalid __ASSERT() level: must be between 0 and 2"
|
||||
|
@ -47,7 +53,7 @@ void assert_post_action(const char *file, unsigned int line);
|
|||
|
||||
#define __ASSERT_LOC(test) \
|
||||
printk("ASSERTION FAIL [%s] @ %s:%d\n", \
|
||||
Z_STRINGIFY(test), \
|
||||
__ASSERT_COND_INFO(test), \
|
||||
__ASSERT_FILE_INFO, \
|
||||
__LINE__) \
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue