fix[DFS][littlefs]: align lseek callback signature with off_t#37
Conversation
align non-DFS_V2 lseek parameter macros with DFS file operation prototypes write back file positions and sizes using off_t and size_t respectively add a compile-time DFS_V1 lseek signature check for RT-Thread 5.0.2+ document the GCC/newlib validation gap versus Keil/IAR type models
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe PR replaces Changesrt_off_t → off_t type correction in seek ABI and truncate ioctl
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
RT-Thread PR #11486 中反馈,最新版 littlefs 在 Keil 编译场景下会出现 DFS
lseek回调函数指针类型不兼容问题:DFS 文件操作表期望off_t (*)(struct dfs_file *, off_t),但 littlefs 适配层当前非 DFS_V2 分支的_dfs_lfs_lseek参数通过DFS_LFS_LSEEK_PARAMS展开为rt_off_t offset。虽然
rt_off_t在 RT-Thread 中确实存在,并定义为rt_base_t,但它不等价于 DFSlseek接口签名要求中的off_t。在部分工具链/配置下,rt_off_t的底层类型可能是signed int,而off_t的底层类型可能是signed long,从而导致函数指针签名不兼容。我这里使用 GCC + DFS_V1 没有出现 warning。分析原因是该构建使用了 newlib,并定义了
RT_USING_LIBC;通过工具查看最终链路可见该 GCC 工具链中__INT32_TYPE__为long int,因此rt_off_t最终也会落到long,未触发类型不兼容问题。littlefs 当前 CI 编译使用
bsp/qemu-vexpress-a9,该路径没有暴露问题;由于没有很好的方案在 CI 中模拟 Keil/IAR 的具体 typedef 实现,这一类兼容性仍需要实际 Keil/IAR 工程验证。你的解决方案是什么 (what is your solution)
DFS_LFS_LSEEK_PARAMS从rt_off_t offset改为off_t offset,使_dfs_lfs_lseek的函数签名与 RT-Thread DFSlseek回调原型保持一致。off_t,文件大小使用size_t。_dfs_lfs_lseek与 DFS 期望的lseek签名一致:这里检查变量绑定到实际的静态函数
_dfs_lfs_lseek,避免仅修改函数实现但没有覆盖到 DFS 回调签名的问题。请提供验证的bsp和config (provide the config and bsp)
bsp/qemu-vexpress-a9,用于 littlefs 现有 GCC CI 路径验证。Keil/IAR 兼容性问题来源于 RT-Thread PR #11486 中的实际工程反馈,仍建议在受影响的 Keil/IAR 工程中做最终验证。无需新增配置项。相关验证配置包括:
GCC 未复现 warning 的路径还包含
RT_USING_LIBC/ newlib 的类型定义影响。not provided yet. 现有 littlefs CI 使用
bsp/qemu-vexpress-a9,不能覆盖 Keil/IAR 的 typedef 差异;Keil/IAR 仍需实际工程验证。]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned upSummary by CodeRabbit
Bug Fixes