From ec1faf3ac524b352e8ba52199a449e117afc04a4 Mon Sep 17 00:00:00 2001 From: Sven Van Asbroeck Date: Thu, 3 Jun 2021 11:26:17 -0400 Subject: [PATCH] rust/kernel: remove `Error::from_kernel_errno()` dead code warning 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 --- rust/kernel/error.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs index 7d059e2152757a..930f6144617eab 100644 --- a/rust/kernel/error.rs +++ b/rust/kernel/error.rs @@ -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.