jingfei195887 opened a new pull request, #22166:
URL: https://github.com/apache/nuttx/pull/22166
## Summary
- **fs/inode: build the foreach_inode() path without snprintf().**
`foreach_inodelevel()` appended each path segment with
`snprintf("/%s")`. Since #21999, `sync()` walks the mountpoints with
`foreach_inode()`, and `sync()` is always linked through the reboot
notifier (`fs_reboot_initialize()`), so an image that does not otherwise
use printf now links the whole printf engine. Copy the segment with
`strlcpy()` instead; the length is already checked against `PATH_MAX`.
Reported by @raiden00pl in
https://github.com/apache/nuttx/pull/21999#issuecomment-7060279365 (size of
minimal images).
## Impact
- No functional change: the path handed to the callbacks is the same.
- Size: images that do not otherwise use printf no longer link it.
- Build, hardware, documentation, security, compatibility: NO.
## Testing
Host: Ubuntu 22.04 x86_64, arm-none-eabi-gcc 10.3.1 and 13.2.1.
Base: master b2b0bde9d0f. Flash = text + data.
`nucleo-f302r8:nsh` reduced to a minimal image: `CONFIG_DEFAULT_SMALL=y`,
`CONFIG_LTO_FULL=y`, `CONFIG_INIT_NONE=y`, no USART/console/syslog
channel, no `/dev` nodes, no procfs/romfs/tmpfs. "revert" is master with
#21999 and #22046 reverted.
| image | gcc 10.3 | gcc 13.2 | printf in image |
|---|---:|---:|---|
| revert #21999 + #22046 | 12152 | 12048 | no |
| master | 15672 (+3520) | 15576 (+3528) | yes |
| this PR | 13220 (+1068) | 13116 (+1068) | no |
| this PR + `CONFIG_DISABLE_MOUNTPOINT=y` | 12124 | 12024 | no |
This PR removes the printf engine (`snprintf`, `__udivmoddi4` and the
stream helpers, about 2.4 KB). The remaining ~1 KB is the mountpoint walk
itself (`sync()` inlined into the reboot handler, `foreach_inodelevel()`,
`mountpt_syncfs()`); `CONFIG_DISABLE_MOUNTPOINT=y` removes it.
- `sim:nsh` with tmpfs mounts at `/x1/y2/z3` and `/t1`: `cat /proc/fs/mount`
and `umount_all()` give the same output before and after.
- `./tools/checkpatch.sh -g master..HEAD`: all checks pass.
- `sim:nsh` Make and CMake builds pass with no warnings in the changed
file; `ostest` exits with status 0.
## PR verification Self-Check
* [x] This PR introduces only one functional change.
* [x] I have updated all required description fields above.
* [x] My PR adheres to Contributing Guidelines and Documentation (git commit
title and message, coding standard, etc).
* [ ] My PR is still work in progress (not ready for review).
* [x] My PR is ready for review and can be safely merged into a codebase.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]