From 8d81cb49e12fd57d8a9981b703e4e0eceacf953d Mon Sep 17 00:00:00 2001 From: neilt6 Date: Mon, 13 Jul 2015 10:20:11 -0600 Subject: [PATCH] [mbed] Modified MBED_ASSERT to use error() Modified mbed_assert_internal() to call error() with the assertation message instead of fprintf() followed by mbed_die(). This allows assertation failures to be caught by custom error() functions that replace the default weak definition. --- libraries/mbed/api/mbed_assert.h | 3 +-- libraries/mbed/common/assert.c | 14 ++------------ 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/libraries/mbed/api/mbed_assert.h b/libraries/mbed/api/mbed_assert.h index 1bcfb092ba..7aed539e76 100644 --- a/libraries/mbed/api/mbed_assert.h +++ b/libraries/mbed/api/mbed_assert.h @@ -23,8 +23,7 @@ extern "C" { /** Internal mbed assert function which is invoked when MBED_ASSERT macro failes. * This function is active only if NDEBUG is not defined prior to including this * assert header file. - * In case of MBED_ASSERT failing condition, the assertation message is printed - * to stderr and mbed_die() is called. + * In case of MBED_ASSERT failing condition, error() is called with the assertation message. * @param expr Expresion to be checked. * @param file File where assertation failed. * @param line Failing assertation line number. diff --git a/libraries/mbed/common/assert.c b/libraries/mbed/common/assert.c index 51394707b0..3d2097ce02 100644 --- a/libraries/mbed/common/assert.c +++ b/libraries/mbed/common/assert.c @@ -14,19 +14,9 @@ * limitations under the License. */ #include "mbed_assert.h" -#include "device.h" - -#if DEVICE_STDIO_MESSAGES -#include -#endif - -#include -#include "mbed_interface.h" +#include "mbed_error.h" void mbed_assert_internal(const char *expr, const char *file, int line) { -#if DEVICE_STDIO_MESSAGES - fprintf(stderr, "mbed assertation failed: %s, file: %s, line %d \n", expr, file, line); -#endif - mbed_die(); + error("mbed assertation failed: %s, file: %s, line %d \n", expr, file, line); }