Skip to content

Commit

Permalink
rust/kernel: remove Error::from_kernel_errno() dead code warning
Browse files Browse the repository at this point in the history
It turns out that we don't need an `Error` constructor that
checks the `errno` invariant at runtime. This is because we
trust return values originating from kernel C. And any return
values originating from Rust code can be constucted using
`Error::` constants, which also do not need a runtime check:

```rust
    return Err(Error::EBUSY);
```

However, there is still ongoing discussion about the merits and
purpose of this function. To facilitate this discussion, keep the
function for the time being, and remove the "dead code" warning.

Signed-off-by: Sven Van Asbroeck <[email protected]>
  • Loading branch information
Sven Van Asbroeck committed Jun 4, 2021
1 parent 79fcf6b commit ec1faf3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rust/kernel/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ impl Error {
///
/// It is a bug to pass an out-of-range `errno`. `EINVAL` would
/// be returned in such a case.
// TODO: remove `dead_code` marker once an in-kernel client is available.
#[allow(dead_code)]
pub(crate) fn from_kernel_errno(errno: c_types::c_int) -> Error {
if errno < -(bindings::MAX_ERRNO as i32) || errno >= 0 {
// TODO: make it a `WARN_ONCE` once available.
Expand Down

0 comments on commit ec1faf3

Please sign in to comment.