Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust/kernel: move from_kernel_result! macro to error.rs #266

Merged
merged 3 commits into from
May 19, 2021

Commits on May 12, 2021

  1. rust/kernel: move from_kernel_result! macro to error.rs

    This macro is well-suited for use elsewhere in the Rust core.
    Move it out to a suitable place, error.rs.
    
    Signed-off-by: Sven Van Asbroeck <thesven73@gmail.com>
    Sven Van Asbroeck committed May 12, 2021
    Configuration menu
    Copy the full SHA
    7dbb95f View commit details
    Browse the repository at this point in the history
  2. rust/kernel: document from_kernel_result! macro

    This is required to pass the CI.
    
    Signed-off-by: Sven Van Asbroeck <thesven73@gmail.com>
    Sven Van Asbroeck committed May 12, 2021
    Configuration menu
    Copy the full SHA
    2ce3372 View commit details
    Browse the repository at this point in the history

Commits on May 18, 2021

  1. 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 <thesven73@gmail.com>
    Sven Van Asbroeck committed May 18, 2021
    Configuration menu
    Copy the full SHA
    eb4c6e8 View commit details
    Browse the repository at this point in the history