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:
authorChristopher Haster <geky@geky.net>2024-01-19 21:23:36 +0300
committerGitHub <noreply@github.com>2024-01-19 21:23:36 +0300
commit1711bdef7682021a231f67105ccfa2746eb5bb14 (patch)
tree1e3f75d8be240ff52013c7c8c9eedb5d7e859073
parent3513ff1afc1d67adb2e6f492f0b9bc0d798fcb0d (diff)
parent6691718b18def310516d1e7724fece766c7c09b1 (diff)
Merge pull request #886 from BrianPugh/macro-sanity-check
Add value-range checks for user-definable macros at compile-time
-rw-r--r--lfs.c15
-rw-r--r--lfs.h6
2 files changed, 17 insertions, 4 deletions
diff --git a/lfs.c b/lfs.c
index a152687..2f10d57 100644
--- a/lfs.c
+++ b/lfs.c
@@ -4108,6 +4108,21 @@ static int lfs_rawremoveattr(lfs_t *lfs, const char *path, uint8_t type) {
/// Filesystem operations ///
+
+// compile time checks, see lfs.h for why these limits exist
+#if LFS_NAME_MAX > 1022
+#error "Invalid LFS_NAME_MAX, must be <= 1022"
+#endif
+
+#if LFS_FILE_MAX > 2147483647
+#error "Invalid LFS_FILE_MAX, must be <= 2147483647"
+#endif
+
+#if LFS_ATTR_MAX > 1022
+#error "Invalid LFS_ATTR_MAX, must be <= 1022"
+#endif
+
+// common filesystem initialization
static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) {
lfs->cfg = cfg;
lfs->block_count = cfg->block_count; // May be 0
diff --git a/lfs.h b/lfs.h
index 9eeab23..452dd0e 100644
--- a/lfs.h
+++ b/lfs.h
@@ -52,10 +52,8 @@ typedef uint32_t lfs_block_t;
#endif
// Maximum size of a file in bytes, may be redefined to limit to support other
-// drivers. Limited on disk to <= 4294967296. However, above 2147483647 the
-// functions lfs_file_seek, lfs_file_size, and lfs_file_tell will return
-// incorrect values due to using signed integers. Stored in superblock and
-// must be respected by other littlefs drivers.
+// drivers. Limited on disk to <= 2147483647. Stored in superblock and must be
+// respected by other littlefs drivers.
#ifndef LFS_FILE_MAX
#define LFS_FILE_MAX 2147483647
#endif