linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rust: acpi: remove unneeded cast to clean future Clippy warning
@ 2025-07-01 17:46 Miguel Ojeda
  2025-07-01 21:38 ` Trevor Gross
  2025-07-07 12:49 ` Alice Ryhl
  0 siblings, 2 replies; 3+ messages in thread
From: Miguel Ojeda @ 2025-07-01 17:46 UTC (permalink / raw)
  To: Rafael J. Wysocki, Greg Kroah-Hartman, Danilo Krummrich,
	Miguel Ojeda, Alex Gaynor
  Cc: Len Brown, linux-acpi, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	rust-for-linux, linux-kernel, patches

A future Clippy warning, `clippy::as_underscore`, is getting enabled in
parallel in the rust-next tree:

    error: using `as _` conversion
      --> rust/kernel/acpi.rs:25:9
       |
    25 |         self.0.driver_data as _
       |         ^^^^^^^^^^^^^^^^^^^^^^-
       |                               |
       |                               help: consider giving the type explicitly: `usize`

The type is already `ulong`, which nowadays is always `usize`, so the
cast is unneeded. Thus remove it, which in turn will avoid the warning
in the future.

Other abstractions of device tables do not use a cast here either.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
I noticed this in -next -- please feel free to rebase if preferred.

 rust/kernel/acpi.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/acpi.rs b/rust/kernel/acpi.rs
index eaae3bc8e54c..2af4d4f92924 100644
--- a/rust/kernel/acpi.rs
+++ b/rust/kernel/acpi.rs
@@ -22,7 +22,7 @@ unsafe impl RawDeviceId for DeviceId {
     const DRIVER_DATA_OFFSET: usize = core::mem::offset_of!(bindings::acpi_device_id, driver_data);

     fn index(&self) -> usize {
-        self.0.driver_data as _
+        self.0.driver_data
     }
 }


base-commit: f5d3ef25d238901a76fe0277787afa44f7714739
--
2.50.0

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

* Re: [PATCH] rust: acpi: remove unneeded cast to clean future Clippy warning
  2025-07-01 17:46 [PATCH] rust: acpi: remove unneeded cast to clean future Clippy warning Miguel Ojeda
@ 2025-07-01 21:38 ` Trevor Gross
  2025-07-07 12:49 ` Alice Ryhl
  1 sibling, 0 replies; 3+ messages in thread
From: Trevor Gross @ 2025-07-01 21:38 UTC (permalink / raw)
  To: Miguel Ojeda, Rafael J. Wysocki, Greg Kroah-Hartman,
	Danilo Krummrich, Alex Gaynor
  Cc: Len Brown, linux-acpi, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, rust-for-linux,
	linux-kernel, patches

On Tue Jul 1, 2025 at 12:46 PM CDT, Miguel Ojeda wrote:
> A future Clippy warning, `clippy::as_underscore`, is getting enabled in
> parallel in the rust-next tree:
>
>     error: using `as _` conversion
>       --> rust/kernel/acpi.rs:25:9
>        |
>     25 |         self.0.driver_data as _
>        |         ^^^^^^^^^^^^^^^^^^^^^^-
>        |                               |
>        |                               help: consider giving the type explicitly: `usize`
>
> The type is already `ulong`, which nowadays is always `usize`, so the
> cast is unneeded. Thus remove it, which in turn will avoid the warning
> in the future.
>
> Other abstractions of device tables do not use a cast here either.
>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

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

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

* Re: [PATCH] rust: acpi: remove unneeded cast to clean future Clippy warning
  2025-07-01 17:46 [PATCH] rust: acpi: remove unneeded cast to clean future Clippy warning Miguel Ojeda
  2025-07-01 21:38 ` Trevor Gross
@ 2025-07-07 12:49 ` Alice Ryhl
  1 sibling, 0 replies; 3+ messages in thread
From: Alice Ryhl @ 2025-07-07 12:49 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Rafael J. Wysocki, Greg Kroah-Hartman, Danilo Krummrich,
	Alex Gaynor, Len Brown, linux-acpi, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, rust-for-linux, linux-kernel, patches

On Tue, Jul 1, 2025 at 7:48 PM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> A future Clippy warning, `clippy::as_underscore`, is getting enabled in
> parallel in the rust-next tree:
>
>     error: using `as _` conversion
>       --> rust/kernel/acpi.rs:25:9
>        |
>     25 |         self.0.driver_data as _
>        |         ^^^^^^^^^^^^^^^^^^^^^^-
>        |                               |
>        |                               help: consider giving the type explicitly: `usize`
>
> The type is already `ulong`, which nowadays is always `usize`, so the
> cast is unneeded. Thus remove it, which in turn will avoid the warning
> in the future.
>
> Other abstractions of device tables do not use a cast here either.
>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

Reviewed-by: Alice Ryhl <aliceryhl@google.com>

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

end of thread, other threads:[~2025-07-07 12:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-01 17:46 [PATCH] rust: acpi: remove unneeded cast to clean future Clippy warning Miguel Ojeda
2025-07-01 21:38 ` Trevor Gross
2025-07-07 12:49 ` Alice Ryhl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).