[PATCH v4 5/6] rust: remove `#[allow(clippy::unnecessary_cast)]`

Onur Özkan posted 6 patches 3 months, 1 week ago
[PATCH v4 5/6] rust: remove `#[allow(clippy::unnecessary_cast)]`
Posted by Onur Özkan 3 months, 1 week ago
This isn't needed anymore since `kernel::ffi::c_int` type
is always `i32` which differs from `err` (isize).

Signed-off-by: Onur Özkan <work@onurozkan.dev>
---
 rust/kernel/error.rs | 1 -
 1 file changed, 1 deletion(-)

diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs
index a59613918d4c..05c6e71c0afb 100644
--- a/rust/kernel/error.rs
+++ b/rust/kernel/error.rs
@@ -413,7 +413,6 @@ pub fn from_err_ptr<T>(ptr: *mut T) -> Result<*mut T> {
         // SAFETY: The FFI function does not deref the pointer.
         let err = unsafe { bindings::PTR_ERR(const_ptr) };

-        #[allow(clippy::unnecessary_cast)]
         // CAST: If `IS_ERR()` returns `true`,
         // then `PTR_ERR()` is guaranteed to return a
         // negative value greater-or-equal to `-bindings::MAX_ERRNO`,
--
2.50.0

Re: [PATCH v4 5/6] rust: remove `#[allow(clippy::unnecessary_cast)]`
Posted by Trevor Gross 3 months ago
On Tue Jul 1, 2025 at 12:35 AM CDT, Onur Özkan wrote:
> This isn't needed anymore since `kernel::ffi::c_int` type
> is always `i32` which differs from `err` (isize).
>
> Signed-off-by: Onur Özkan <work@onurozkan.dev>
> ---
>  rust/kernel/error.rs | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs
> index a59613918d4c..05c6e71c0afb 100644
> --- a/rust/kernel/error.rs
> +++ b/rust/kernel/error.rs
> @@ -413,7 +413,6 @@ pub fn from_err_ptr<T>(ptr: *mut T) -> Result<*mut T> {
>          // SAFETY: The FFI function does not deref the pointer.
>          let err = unsafe { bindings::PTR_ERR(const_ptr) };
>
> -        #[allow(clippy::unnecessary_cast)]
>          // CAST: If `IS_ERR()` returns `true`,
>          // then `PTR_ERR()` is guaranteed to return a
>          // negative value greater-or-equal to `-bindings::MAX_ERRNO`,
> --
> 2.50.0

Reviewed-by: Trevor Gross <tmgross@umich.edu>