Rust for Linux List
 help / color / mirror / Atom feed
* [PATCH v3] rust: error: make conversion functions public
@ 2024-09-13 10:19 Filipe Xavier
  2024-09-13 10:26 ` Benno Lossin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Filipe Xavier @ 2024-09-13 10:19 UTC (permalink / raw)
  To: aliceryhl, ojeda, boqun.feng, alex.gaynor, benno.lossin
  Cc: rust-for-linux, Filipe Xavier

Change visibility to public of functions in error.rs:
from_err_ptr, from_errno, from_result and to_ptr. 
Additionally, remove dead_code annotations.

Link: https://github.com/Rust-for-Linux/linux/issues/1105
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Filipe Xavier <felipe_life@live.com>

---
 rust/kernel/error.rs | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs
index 6f1587a2524e..d7965ded2973 100644
--- a/rust/kernel/error.rs
+++ b/rust/kernel/error.rs
@@ -95,7 +95,7 @@ impl Error {
     ///
     /// It is a bug to pass an out-of-range `errno`. `EINVAL` would
     /// be returned in such a case.
-    pub(crate) fn from_errno(errno: core::ffi::c_int) -> Error {
+    pub fn from_errno(errno: core::ffi::c_int) -> Error {
         if errno < -(bindings::MAX_ERRNO as i32) || errno >= 0 {
             // TODO: Make it a `WARN_ONCE` once available.
             crate::pr_warn!(
@@ -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>,
-- 
2.46.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] rust: error: make conversion functions public
  2024-09-13 10:19 [PATCH v3] rust: error: make conversion functions public Filipe Xavier
@ 2024-09-13 10:26 ` Benno Lossin
  2024-09-13 13:29 ` Gary Guo
  2024-10-03 21:49 ` Miguel Ojeda
  2 siblings, 0 replies; 4+ messages in thread
From: Benno Lossin @ 2024-09-13 10:26 UTC (permalink / raw)
  To: Filipe Xavier, aliceryhl, ojeda, boqun.feng, alex.gaynor; +Cc: rust-for-linux

On 13.09.24 12:19, Filipe Xavier wrote:
> Change visibility to public of functions in error.rs:
> from_err_ptr, from_errno, from_result and to_ptr.
> Additionally, remove dead_code annotations.
> 
> Link: https://github.com/Rust-for-Linux/linux/issues/1105
> Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> Signed-off-by: Filipe Xavier <felipe_life@live.com>
> 
> ---
>  rust/kernel/error.rs | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)

Reviewed-by: Benno Lossin <benno.lossin@proton.me>

---
Cheers,
Benno


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] rust: error: make conversion functions public
  2024-09-13 10:19 [PATCH v3] rust: error: make conversion functions public Filipe Xavier
  2024-09-13 10:26 ` Benno Lossin
@ 2024-09-13 13:29 ` Gary Guo
  2024-10-03 21:49 ` Miguel Ojeda
  2 siblings, 0 replies; 4+ messages in thread
From: Gary Guo @ 2024-09-13 13:29 UTC (permalink / raw)
  To: Filipe Xavier
  Cc: aliceryhl, ojeda, boqun.feng, alex.gaynor, benno.lossin,
	rust-for-linux

On Fri, 13 Sep 2024 07:19:56 -0300
Filipe Xavier <felipe_life@live.com> wrote:

> Change visibility to public of functions in error.rs:
> from_err_ptr, from_errno, from_result and to_ptr. 
> Additionally, remove dead_code annotations.
> 
> Link: https://github.com/Rust-for-Linux/linux/issues/1105
> Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> Signed-off-by: Filipe Xavier <felipe_life@live.com>

Reviewed-by: Gary Guo <gary@garyguo.net>

> 
> ---
>  rust/kernel/error.rs | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] rust: error: make conversion functions public
  2024-09-13 10:19 [PATCH v3] rust: error: make conversion functions public Filipe Xavier
  2024-09-13 10:26 ` Benno Lossin
  2024-09-13 13:29 ` Gary Guo
@ 2024-10-03 21:49 ` Miguel Ojeda
  2 siblings, 0 replies; 4+ messages in thread
From: Miguel Ojeda @ 2024-10-03 21:49 UTC (permalink / raw)
  To: Filipe Xavier
  Cc: aliceryhl, ojeda, boqun.feng, alex.gaynor, benno.lossin,
	rust-for-linux

On Fri, Sep 13, 2024 at 12:20 PM Filipe Xavier <felipe_life@live.com> wrote:
>
> Change visibility to public of functions in error.rs:
> from_err_ptr, from_errno, from_result and to_ptr.
> Additionally, remove dead_code annotations.
>
> Link: https://github.com/Rust-for-Linux/linux/issues/1105
> Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> Signed-off-by: Filipe Xavier <felipe_life@live.com>

Applied to `rust-next` -- thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-03 21:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-13 10:19 [PATCH v3] rust: error: make conversion functions public Filipe Xavier
2024-09-13 10:26 ` Benno Lossin
2024-09-13 13:29 ` Gary Guo
2024-10-03 21:49 ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox