From afc3306d25e37e87554bd90689d3f7c6202570af Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Fri, 23 Feb 2018 17:45:24 -0600 Subject: [PATCH] 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. --- features/filesystem/littlefs/littlefs/lfs_util.h | 16 ++++++++++------ features/filesystem/littlefs/mbed_lib.json | 5 +++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/features/filesystem/littlefs/littlefs/lfs_util.h b/features/filesystem/littlefs/littlefs/lfs_util.h index b05d118f4b..e5175064fe 100644 --- a/features/filesystem/littlefs/littlefs/lfs_util.h +++ b/features/filesystem/littlefs/littlefs/lfs_util.h @@ -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 diff --git a/features/filesystem/littlefs/mbed_lib.json b/features/filesystem/littlefs/mbed_lib.json index bafc549f5c..0924d8aa4e 100644 --- a/features/filesystem/littlefs/mbed_lib.json +++ b/features/filesystem/littlefs/mbed_lib.json @@ -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" } } }