Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rust/kernel: improve from_kernel_result! macro safety
`from_kernel_result!` could panic if the return integer type (`T`) is unable to hold the negative `errno`. Since `errno`s range from `1` to `4095`, functions returning integer types unable to hold values in the [-4095, -1] range could potentially panic. This includes all unsigned integers, and signed integers with insufficient bits, such as `c_char`. Fix by making sure that the return integer type is always suitable to hold the negative `errno`. Use the Rust type system to verify this at build time. Signed-off-by: Sven Van Asbroeck <[email protected]>
- Loading branch information