assert: Add option to disable assertion messages
Add option to disable the assertion message, this makes all __ASSERT behave as __ASSERT_NO_MSG instead. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
7a433325f5
commit
4af5815bf4
2 changed files with 16 additions and 1 deletions
|
@ -38,6 +38,12 @@
|
||||||
#define __ASSERT_COND_INFO(test) Z_STRINGIFY(test)
|
#define __ASSERT_COND_INFO(test) Z_STRINGIFY(test)
|
||||||
#endif /* CONFIG_ASSERT_NO_COND_INFO */
|
#endif /* CONFIG_ASSERT_NO_COND_INFO */
|
||||||
|
|
||||||
|
#ifdef CONFIG_ASSERT_NO_MSG_INFO
|
||||||
|
#define __ASSERT_MSG_INFO(fmt, ...)
|
||||||
|
#else /* CONFIG_ASSERT_NO_MSG_INFO */
|
||||||
|
#define __ASSERT_MSG_INFO(fmt, ...) __ASSERT_PRINT("\t" fmt "\n", ##__VA_ARGS__)
|
||||||
|
#endif /* CONFIG_ASSERT_NO_MSG_INFO */
|
||||||
|
|
||||||
#define __ASSERT_LOC(test) \
|
#define __ASSERT_LOC(test) \
|
||||||
__ASSERT_PRINT("ASSERTION FAIL [%s] @ %s:%d\n", \
|
__ASSERT_PRINT("ASSERTION FAIL [%s] @ %s:%d\n", \
|
||||||
__ASSERT_COND_INFO(test), \
|
__ASSERT_COND_INFO(test), \
|
||||||
|
@ -75,7 +81,7 @@ void assert_post_action(const char *file, unsigned int line);
|
||||||
do { \
|
do { \
|
||||||
if (!(test)) { \
|
if (!(test)) { \
|
||||||
__ASSERT_LOC(test); \
|
__ASSERT_LOC(test); \
|
||||||
printk("\t" fmt "\n", ##__VA_ARGS__); \
|
__ASSERT_MSG_INFO(fmt, ##__VA_ARGS__); \
|
||||||
assert_post_action(__ASSERT_FILE_INFO, __LINE__); \
|
assert_post_action(__ASSERT_FILE_INFO, __LINE__); \
|
||||||
} \
|
} \
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
|
@ -206,6 +206,15 @@ config ASSERT_NO_COND_INFO
|
||||||
info before disabling file info since the condition can be found in
|
info before disabling file info since the condition can be found in
|
||||||
the source using file info.
|
the source using file info.
|
||||||
|
|
||||||
|
config ASSERT_NO_MSG_INFO
|
||||||
|
bool "Disable message for asserts"
|
||||||
|
help
|
||||||
|
This option removes the additional message from the printed assert.
|
||||||
|
Enabling this will save target code space, and thus may be
|
||||||
|
necessary for tiny targets. It is recommended to disable message
|
||||||
|
before disabling file info since the message can be found in the
|
||||||
|
source using file info.
|
||||||
|
|
||||||
config OBJECT_TRACING
|
config OBJECT_TRACING
|
||||||
bool "Kernel object tracing"
|
bool "Kernel object tracing"
|
||||||
help
|
help
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue