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:
Joakim Andersson 2019-12-20 16:21:52 +01:00 committed by Alberto Escolar
commit 4af5815bf4
2 changed files with 16 additions and 1 deletions

View file

@ -38,6 +38,12 @@
#define __ASSERT_COND_INFO(test) Z_STRINGIFY(test)
#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) \
__ASSERT_PRINT("ASSERTION FAIL [%s] @ %s:%d\n", \
__ASSERT_COND_INFO(test), \
@ -75,7 +81,7 @@ void assert_post_action(const char *file, unsigned int line);
do { \
if (!(test)) { \
__ASSERT_LOC(test); \
printk("\t" fmt "\n", ##__VA_ARGS__); \
__ASSERT_MSG_INFO(fmt, ##__VA_ARGS__); \
assert_post_action(__ASSERT_FILE_INFO, __LINE__); \
} \
} while (false)

View file

@ -206,6 +206,15 @@ config ASSERT_NO_COND_INFO
info before disabling file info since the condition can be found in
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
bool "Kernel object tracing"
help