Tried to use correct types for cfg/fsinfo things

In theory, lfs3_size_t should be used for in-block sizes (though this is
also mixed up with in-device sizes?), lfs3_off_t for file sizes, and
lfs3_block_t for block counts (I don't think lfs3_off_t/lfs3_block_t
will ever differ, but the notation is helpful).

Though I've not done a great job at keeping these types organized...

Changed:

- cfg.block_count:      lfs3_size_t  -> lfs3_block_t
- cfg.file_limit:       lfs3_size_t  -> lfs3_off_t
- fsinfo.block_count:   lfs3_size_t  -> lfs3_block_t
- fsinfo.file_limit:    lfs3_size_t  -> lfs3_off_t
- lfs3_fs_usage:        lfs3_ssize_t -> lfs3_sblock_t
- geometry.block_size:  lfs3_size_t  -> lfs3_off_t
- geometry.block_count: lfs3_size_t  -> lfs3_block_t
- and some internals

No code changes.
This commit is contained in:
Christopher Haster
2025-12-02 14:37:08 -06:00
parent 7d9fe534d1
commit 1abd9d732f
2 changed files with 10 additions and 10 deletions
+4 -4
View File
@@ -15197,8 +15197,8 @@ static inline int lfs3_data_readocompat(lfs3_t *lfs3, lfs3_data_t *data,
// //
// note these are stored minus 1 to avoid overflow issues // note these are stored minus 1 to avoid overflow issues
struct lfs3_geometry { struct lfs3_geometry {
lfs3_off_t block_size; lfs3_size_t block_size;
lfs3_off_t block_count; lfs3_block_t block_count;
}; };
// geometry on-disk encoding // geometry on-disk encoding
@@ -16102,8 +16102,8 @@ int lfs3_fs_stat(lfs3_t *lfs3, struct lfs3_fsinfo *fsinfo) {
return 0; return 0;
} }
lfs3_ssize_t lfs3_fs_usage(lfs3_t *lfs3) { lfs3_sblock_t lfs3_fs_usage(lfs3_t *lfs3) {
lfs3_size_t count = 0; lfs3_block_t count = 0;
lfs3_mtrv_t mtrv; lfs3_mtrv_t mtrv;
lfs3_mtrv_init(&mtrv, LFS3_T_RDONLY); lfs3_mtrv_init(&mtrv, LFS3_T_RDONLY);
while (true) { while (true) {
+6 -6
View File
@@ -472,7 +472,7 @@ struct lfs3_cfg {
lfs3_size_t block_size; lfs3_size_t block_size;
// Number of erasable blocks on the device. // Number of erasable blocks on the device.
lfs3_size_t block_count; lfs3_block_t block_count;
// Number of erase cycles before metadata blocks are relocated for // Number of erase cycles before metadata blocks are relocated for
// wear-leveling. Suggested values are in the range 16-1024. Larger values // wear-leveling. Suggested values are in the range 16-1024. Larger values
@@ -601,7 +601,7 @@ struct lfs3_cfg {
// but must be <= LFS3_FILE_MAX. Defaults to LFS3_FILE_MAX when zero. Stored // but must be <= LFS3_FILE_MAX. Defaults to LFS3_FILE_MAX when zero. Stored
// in superblock and must be respected by other littlefs drivers. // in superblock and must be respected by other littlefs drivers.
#ifndef LFS3_RDONLY #ifndef LFS3_RDONLY
lfs3_size_t file_limit; lfs3_off_t file_limit;
#endif #endif
// TODO these are pretty low-level details, should we have reasonable // TODO these are pretty low-level details, should we have reasonable
@@ -680,13 +680,13 @@ struct lfs3_fsinfo {
lfs3_size_t block_size; lfs3_size_t block_size;
// Number of logical blocks in the filesystem. // Number of logical blocks in the filesystem.
lfs3_size_t block_count; lfs3_block_t block_count;
// Upper limit on the length of file names in bytes. // Upper limit on the length of file names in bytes.
lfs3_size_t name_limit; lfs3_size_t name_limit;
// Upper limit on the size of files in bytes. // Upper limit on the size of files in bytes.
lfs3_size_t file_limit; lfs3_off_t file_limit;
}; };
// Traversal info structure // Traversal info structure
@@ -1230,7 +1230,7 @@ typedef struct lfs3_gbmap {
typedef struct lfs3 { typedef struct lfs3 {
const struct lfs3_cfg *cfg; const struct lfs3_cfg *cfg;
uint32_t flags; uint32_t flags;
lfs3_size_t block_count; lfs3_block_t block_count;
lfs3_size_t name_limit; lfs3_size_t name_limit;
lfs3_off_t file_limit; lfs3_off_t file_limit;
@@ -1670,7 +1670,7 @@ int lfs3_fs_stat(lfs3_t *lfs3, struct lfs3_fsinfo *fsinfo);
// usage may be larger than the filesystem actually is. // usage may be larger than the filesystem actually is.
// //
// Returns the number of allocated blocks, or a negative error code on failure. // Returns the number of allocated blocks, or a negative error code on failure.
lfs3_ssize_t lfs3_fs_usage(lfs3_t *lfs3); lfs3_sblock_t lfs3_fs_usage(lfs3_t *lfs3);
// Get the current filesystem checksum // Get the current filesystem checksum
// //