Merge pull request #1161 from amubiera/size-t-warnings

Fixes for 'Implicit conversion loses integer precision' warnings.
This commit is contained in:
Christopher Haster
2026-03-24 17:25:43 -05:00
committed by GitHub
+4 -4
View File
@@ -286,7 +286,7 @@ static int lfs_bd_erase(lfs_t *lfs, lfs_block_t block) {
// some operations on paths // some operations on paths
static inline lfs_size_t lfs_path_namelen(const char *path) { static inline lfs_size_t lfs_path_namelen(const char *path) {
return strcspn(path, "/"); return (lfs_size_t)strcspn(path, "/");
} }
static inline bool lfs_path_islast(const char *path) { static inline bool lfs_path_islast(const char *path) {
@@ -1501,7 +1501,7 @@ nextname:
if (lfs_tag_type3(tag) == LFS_TYPE_DIR) { if (lfs_tag_type3(tag) == LFS_TYPE_DIR) {
name += strspn(name, "/"); name += strspn(name, "/");
} }
lfs_size_t namelen = strcspn(name, "/"); lfs_size_t namelen = (lfs_size_t)strcspn(name, "/");
// skip '.' // skip '.'
if (namelen == 1 && memcmp(name, ".", 1) == 0) { if (namelen == 1 && memcmp(name, ".", 1) == 0) {
@@ -1520,7 +1520,7 @@ nextname:
int depth = 1; int depth = 1;
while (true) { while (true) {
suffix += strspn(suffix, "/"); suffix += strspn(suffix, "/");
sufflen = strcspn(suffix, "/"); sufflen = (lfs_size_t)strcspn(suffix, "/");
if (sufflen == 0) { if (sufflen == 0) {
break; break;
} }
@@ -1761,7 +1761,7 @@ static int lfs_dir_commitcrc(lfs_t *lfs, struct lfs_commit *commit) {
commit->off = noff; commit->off = noff;
// perturb valid bit? // perturb valid bit?
commit->ptag = ntag ^ ((0x80UL & ~eperturb) << 24); commit->ptag = ntag ^ ((lfs_tag_t)(0x80 & ~eperturb) << 24);
// reset crc for next commit // reset crc for next commit
commit->crc = 0xffffffff; commit->crc = 0xffffffff;