From 93dc3be19450447a3a7090bd1dfb9f3daac3e8d2 Mon Sep 17 00:00:00 2001 From: Filipe Xavier Date: Sat, 7 Sep 2024 14:50:33 +0200 Subject: [PATCH] rust: error.rs: Remove dead_code marker and make from_err_ptr, from_result and to_ptr public Remove dead_code annotation from from_err_ptr, from_result and to_ptr functions in error.rs file and change visibility to public, making it accessible outside the kernel crate(issue #1105). Signed-off-by: Filipe Xavier --- diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs index 6f1587a2524e..ecfa6aa41034 100644 --- a/rust/kernel/error.rs +++ b/rust/kernel/error.rs @@ -133,8 +133,7 @@ pub(crate) fn to_blk_status(self) -> bindings::blk_status_t { } /// Returns the error encoded as a pointer. - #[allow(dead_code)] - pub(crate) fn to_ptr(self) -> *mut T { + pub fn to_ptr(self) -> *mut T { #[cfg_attr(target_pointer_width = "32", allow(clippy::useless_conversion))] // SAFETY: `self.0` is a valid error due to its invariant. unsafe { @@ -268,9 +267,7 @@ pub fn to_result(err: core::ffi::c_int) -> Result { /// from_err_ptr(unsafe { bindings::devm_platform_ioremap_resource(pdev.to_ptr(), index) }) /// } /// ``` -// TODO: Remove `dead_code` marker once an in-kernel client is available. -#[allow(dead_code)] -pub(crate) fn from_err_ptr(ptr: *mut T) -> Result<*mut T> { +pub fn from_err_ptr(ptr: *mut T) -> Result<*mut T> { // CAST: Casting a pointer to `*const core::ffi::c_void` is always valid. let const_ptr: *const core::ffi::c_void = ptr.cast(); // SAFETY: The FFI function does not deref the pointer. @@ -315,9 +312,7 @@ pub(crate) fn from_err_ptr(ptr: *mut T) -> Result<*mut T> { /// }) /// } /// ``` -// TODO: Remove `dead_code` marker once an in-kernel client is available. -#[allow(dead_code)] -pub(crate) fn from_result(f: F) -> T +pub fn from_result(f: F) -> T where T: From, F: FnOnce() -> Result,