diff --git a/subsys/bluetooth/common/Kconfig b/subsys/bluetooth/common/Kconfig index 2c9b97a270a..f66ede26d0c 100644 --- a/subsys/bluetooth/common/Kconfig +++ b/subsys/bluetooth/common/Kconfig @@ -61,8 +61,7 @@ config BT_ASSERT default y help Use a custom Bluetooth assert implementation instead of the - kernel-wide __ASSERT(), which is enabled by CONFIG_ASSERT and is - disabled by default. + kernel-wide __ASSERT() when CONFIG_ASSERT is disabled. if BT_ASSERT diff --git a/subsys/bluetooth/common/log.h b/subsys/bluetooth/common/log.h index c4f526bbba0..d17a9a27323 100644 --- a/subsys/bluetooth/common/log.h +++ b/subsys/bluetooth/common/log.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -42,9 +43,9 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, LOG_LEVEL); #define BT_INFO(fmt, ...) LOG_INF(fmt, ##__VA_ARGS__) #if defined(CONFIG_BT_ASSERT_VERBOSE) -#define BT_ASSERT_PRINT(fmt, ...) printk(fmt, ##__VA_ARGS__) +#define BT_ASSERT_PRINT(test) __ASSERT_LOC(test) #else -#define BT_ASSERT_PRINT(fmt, ...) +#define BT_ASSERT_PRINT(test) #endif /* CONFIG_BT_ASSERT_VERBOSE */ #if defined(CONFIG_BT_ASSERT_PANIC) @@ -54,11 +55,13 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, LOG_LEVEL); #endif /* CONFIG_BT_ASSERT_PANIC */ #if defined(CONFIG_BT_ASSERT) -#define BT_ASSERT(cond) if (!(cond)) { \ - BT_ASSERT_PRINT("assert: '" #cond \ - "' failed\n"); \ - BT_ASSERT_DIE(); \ - } +#define BT_ASSERT(cond) \ + do { \ + if (!(cond)) { \ + BT_ASSERT_PRINT(cond); \ + BT_ASSERT_DIE(); \ + } \ + } while (0) #else #define BT_ASSERT(cond) __ASSERT_NO_MSG(cond) #endif/* CONFIG_BT_ASSERT*/