refactor: 清理匿名 Result 错误类型#256
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors error handling across the kernel, replacing generic Result<(), ()> types with structured error enums such as PagingError, NetworkError, FsError, FlockRangeError, RingBufferError, and StringCopyError. System calls, virtual memory operations, and network stack functions now propagate these detailed errors and convert them to appropriate system error codes (errno). Additionally, the default error for unsupported lseek operations has been updated from NotSupported to NotSeekable. A security improvement is recommended in get_args_safe to limit the number of arguments copied from user space to MAX_ARGV, preventing potential denial-of-service (OOM) attacks from excessively long argument lists.
变更内容
本 PR 处理 #246,主要清理内核中的
Result<_, ()>/Result<(), ()>匿名错误类型,避免底层错误在跨模块传播时被湮灭。PageTableInner::new()/new_as_kernel_table()改为 fallible 初始化,移除页表创建路径中的分配失败 panicNetworkError,替代匿名()main,解决架构抽象重构后的冲突验证情况
cargo fmt --all -- --checkcargo check --target riscv64gc-unknown-none-elfcargo clippy --target riscv64gc-unknown-none-elfmake run TEST=1make run TEST=1结果:Total: 510, Passed: 510, Failed: 0额外确认:
rg "Result<[^\n]*, \(\)>|Result<\(\), \(\)>" os/src -n无结果PageTableInner::new().unwrap()/new_as_kernel_table().unwrap()无结果Closes #246