lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID:
 <DM4PR14MB72760296911674F92C7A6C01E99F2@DM4PR14MB7276.namprd14.prod.outlook.com>
Date: Sat, 7 Sep 2024 18:19:01 +0000
From: Felipe Alves <felipe_life@...e.com>
To: "aliceryhl@...gle.com" <aliceryhl@...gle.com>, "ojeda@...nel.org"
	<ojeda@...nel.org>, "alex.gaynor@...il.com" <alex.gaynor@...il.com>,
	"masahiroy@...nel.org" <masahiroy@...nel.org>
CC: Felipe Alves <felipe_life@...e.com>, "boqun.feng@...il.com"
	<boqun.feng@...il.com>, "gary@...yguo.net" <gary@...yguo.net>,
	"rust-for-linux@...r.kernel.org" <rust-for-linux@...r.kernel.org>,
	"nathan@...nel.org" <nathan@...nel.org>, "nicolas@...sle.eu"
	<nicolas@...sle.eu>, "linux-kbuild@...r.kernel.org"
	<linux-kbuild@...r.kernel.org>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>, "patches@...ts.linux.dev"
	<patches@...ts.linux.dev>
Subject: [PATCH] rust: error.rs: Remove dead_code marker and make
 from_err_ptr, from_result and to_ptr public

>From 93dc3be19450447a3a7090bd1dfb9f3daac3e8d2 Mon Sep 17 00:00:00 2001
From: Filipe Xavier <felipe_life@...e.com>
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 <felipe_life@...e.com>
---
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<T>(self) -> *mut T {
+    pub fn to_ptr<T>(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<T>(ptr: *mut T) -> Result<*mut T> {
+pub fn from_err_ptr<T>(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<T>(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<T, F>(f: F) -> T
+pub fn from_result<T, F>(f: F) -> T
 where
     T: From<i16>,
     F: FnOnce() -> Result<T>,

Content of type "text/html" skipped

View attachment "0001-make-public-functions-on-error-rs.patch" of type "text/x-patch" (2029 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ