fs/driver: Replace heap allocation of temporary device names#17839
Merged
xiaoxiang781216 merged 1 commit intoapache:masterfrom Jan 14, 2026
Merged
fs/driver: Replace heap allocation of temporary device names#17839xiaoxiang781216 merged 1 commit intoapache:masterfrom
xiaoxiang781216 merged 1 commit intoapache:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the unique device name generation for MTD and block device proxies by replacing heap-allocated device names with stack-allocated local buffers. The change modifies unique_blkdev and unique_chardev functions to accept a buffer parameter instead of returning an allocated string, eliminating the need for heap allocation and deallocation.
Changes:
- Modified
unique_blkdevandunique_chardevto use caller-provided buffers instead of allocating strings - Updated error handling to return integer status codes instead of NULL pointers
- Simplified cleanup logic by removing goto labels and heap deallocation calls
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| fs/driver/fs_mtdproxy.c | Changed unique_blkdev to accept buffer parameter, updated mtd_proxy to use stack-allocated device name array |
| fs/driver/fs_blockproxy.c | Changed unique_chardev to accept buffer parameter, updated block_proxy to use stack-allocated device name (incorrectly left as pointer) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
14c0f33 to
5e8ccee
Compare
jerpelea
previously approved these changes
Jan 12, 2026
5e8ccee to
2709601
Compare
2709601 to
a2b2c16
Compare
To simplify the handling of Block devices and MTD devices, the unique_chardev and unique_blkdev functions now use local variable names instead of allocating device names from the heap. Signed-off-by: jingfei <jingfei@xiaomi.com>
a2b2c16 to
5be427f
Compare
xiaoxiang781216
approved these changes
Jan 13, 2026
jerpelea
approved these changes
Jan 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
To simplify the handling of Block devices and MTD devices, the unique_chardev and unique_blkdev functions now use local variable names instead of allocating device names from the heap.
Impact
Very minor optimization.
Testing
Run the examples/mtdpart in sim:nsh for test an test is passed.