littlefs: Adopted MBED_ASSERT and littlefs.enable_assert

Much like the logging functions, assertions can be enabled, disabled
and forced with the littlefs.enable_assert config option. Integrates
with the new LFS_ASSERT macro.
pull/6179/head
Christopher Haster 2018-02-23 17:45:24 -06:00
parent 453a1b6815
commit afc3306d25
2 changed files with 15 additions and 6 deletions

View File

@ -37,16 +37,18 @@
// macros must not have side-effects as the macros can be removed for a smaller
// code footprint
// Logging functions
#ifdef __MBED__
#include "mbed_debug.h"
#include "mbed_assert.h"
#else
#define MBED_LFS_ENABLE_INFO false
#define MBED_LFS_ENABLE_DEBUG true
#define MBED_LFS_ENABLE_WARN true
#define MBED_LFS_ENABLE_ERROR true
#define MBED_LFS_ENABLE_INFO false
#define MBED_LFS_ENABLE_DEBUG true
#define MBED_LFS_ENABLE_WARN true
#define MBED_LFS_ENABLE_ERROR true
#define MBED_LFS_ENABLE_ASSERT true
#endif
// Logging functions
#if !defined(LFS_NO_INFO) && MBED_LFS_ENABLE_INFO
#define LFS_INFO(fmt, ...) printf("lfs info:%d: " fmt "\n", __LINE__, __VA_ARGS__)
#elif !defined(LFS_NO_INFO) && !defined(MBED_LFS_ENABLE_INFO)
@ -80,8 +82,10 @@
#endif
// Runtime assertions
#ifndef LFS_NO_ASSERT
#if !defined(LFS_NO_ASSERT) && MBED_LFS_ENABLE_ASSERT
#define LFS_ASSERT(test) assert(test)
#elif !defined(LFS_NO_ASSERT) && !defined(MBED_LFS_ENABLE_ASSERT)
#define LFS_ASSERT(test) MBED_ASSERT(test)
#else
#define LFS_ASSERT(test)
#endif

View File

@ -40,6 +40,11 @@
"macro_name": "MBED_LFS_ENABLE_ERROR",
"value": null,
"help": "Enables error logging, true = enabled, false = disabled, null = disabled only in release builds"
},
"enable_assert": {
"macro_name": "MBED_LFS_ENABLE_ASSERT",
"value": null,
"help": "Enables asserts, true = enabled, false = disabled, null = disabled only in release builds"
}
}
}