Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/littlefs-project/littlefs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Pugh <bnp117@gmail.com>2023-10-29 23:50:38 +0300
committerBrian Pugh <bnp117@gmail.com>2023-10-29 23:50:38 +0300
commit8f9427dd53cc3f5eb9194f1235e6357fab5b476d (patch)
tree7bc21c680019ec3d8c2bc99f28163402c3b07a18
parentf77214d1f0a8ccd7ddc7e1204fedd25ee5a41534 (diff)
Add value-range checks for user-definable macros
-rw-r--r--lfs.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lfs.c b/lfs.c
index 0827331..6c517a4 100644
--- a/lfs.c
+++ b/lfs.c
@@ -8,6 +8,23 @@
#include "lfs.h"
#include "lfs_util.h"
+// Configuration Sanity Check
+#if (LFS_NAME_MAX <= 0) || (LFS_NAME_MAX > 1022)
+#error "LFS_NAME_MAX must be in the range (0, 1022]"
+#endif
+
+#if (LFS_FILE_MAX <= 0) || (LFS_FILE_MAX > 4294967296)
+#error "LFS_FILE_MAX must be in the range (0, 4294967296]"
+#endif
+
+#if (LFS_FILE_MAX > 2147483647)
+#warning "LFS_FILE_MAX>2147483647; lfs_file_seek, lfs_file_size, and lfs_file_tell will not function properly."
+#endif
+
+#if (LFS_ATTR_MAX < 0) || (LFS_ATTR_MAX > 1022)
+#error "LFS_ATTR_MAX must be in the range [0, 1022]"
+#endif
+
// some constants used throughout the code
#define LFS_BLOCK_NULL ((lfs_block_t)-1)