Skip to content

Commit ec1faf3

Browse files
author
Sven Van Asbroeck
committed
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 <[email protected]>
1 parent 79fcf6b commit ec1faf3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

rust/kernel/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ impl Error {
6464
///
6565
/// It is a bug to pass an out-of-range `errno`. `EINVAL` would
6666
/// be returned in such a case.
67+
// TODO: remove `dead_code` marker once an in-kernel client is available.
68+
#[allow(dead_code)]
6769
pub(crate) fn from_kernel_errno(errno: c_types::c_int) -> Error {
6870
if errno < -(bindings::MAX_ERRNO as i32) || errno >= 0 {
6971
// TODO: make it a `WARN_ONCE` once available.

0 commit comments

Comments
 (0)