Skip to content

fs/driver: Replace heap allocation of temporary device names#17839

Merged
xiaoxiang781216 merged 1 commit intoapache:masterfrom
jingfei195887:optimize_proxy
Jan 14, 2026
Merged

fs/driver: Replace heap allocation of temporary device names#17839
xiaoxiang781216 merged 1 commit intoapache:masterfrom
jingfei195887:optimize_proxy

Conversation

@jingfei195887
Copy link
Contributor

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.

Copilot AI review requested due to automatic review settings January 12, 2026 14:20
@github-actions github-actions bot added Area: File System File System issues Size: S The size of the change in this PR is small labels Jan 12, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_blkdev and unique_chardev to 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.

@jingfei195887 jingfei195887 force-pushed the optimize_proxy branch 2 times, most recently from 14c0f33 to 5e8ccee Compare January 12, 2026 14:29
@jerpelea jerpelea changed the title Replaced heap allocation of temporary device names fs/driver: Replace heap allocation of temporary device names Jan 12, 2026
jerpelea
jerpelea previously approved these changes Jan 12, 2026
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>
@xiaoxiang781216 xiaoxiang781216 merged commit c3010ea into apache:master Jan 14, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: File System File System issues Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants