Skip to content

Commit

Permalink
Restricted LFS_FILE_MAX to signed 32-bits, <2^31, <=2147483647
Browse files Browse the repository at this point in the history
I think realistically no one is using this. It's already only partially
supported and untested.

Worst case, if someone does depend on this we can always revert.
  • Loading branch information
geky committed Jan 17, 2024
1 parent 1fefcbb commit 6691718
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4112,8 +4112,8 @@ static int lfs_rawremoveattr(lfs_t *lfs, const char *path, uint8_t type) {
#error "Invalid LFS_NAME_MAX, must be <= 1022"
#endif

#if LFS_FILE_MAX > 4294967295
#error "Invalid LFS_FILE_MAX, must be <= 4294967295"
#if LFS_FILE_MAX > 2147483647
#error "Invalid LFS_FILE_MAX, must be <= 2147483647"
#endif

#if LFS_ATTR_MAX > 1022
Expand Down
6 changes: 2 additions & 4 deletions lfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <= 4294967295. 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
Expand Down

0 comments on commit 6691718

Please sign in to comment.