]> Git Repo - J-linux.git/commitdiff
rust: miscdevice: fix warning on c_uint to u32 cast
authorAlice Ryhl <[email protected]>
Tue, 15 Oct 2024 14:13:22 +0000 (14:13 +0000)
committerGreg Kroah-Hartman <[email protected]>
Tue, 15 Oct 2024 17:11:39 +0000 (19:11 +0200)
When building miscdevice with clippy warnings, the following warning is
emitted:

warning: casting to the same type is unnecessary (`u32` -> `u32`)
   --> /home/aliceryhl/rust-for-linux/rust/kernel/miscdevice.rs:220:28
    |
220 |     match T::ioctl(device, cmd as u32, arg as usize) {
    |                            ^^^^^^^^^^ help: try: `cmd`
    |
    = help: for further information visit
      https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
    = note: `-W clippy::unnecessary-cast` implied by `-W clippy::all`
    = help: to override `-W clippy::all` add `#[allow(clippy::unnecessary_cast)]`

Thus, fix it.

Signed-off-by: Alice Ryhl <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
rust/kernel/miscdevice.rs

index cbd5249b5b45d2fd3ade4517875935a1a893f0a2..50885fb511bf2b6bee17e74b1c3a3b68359726c9 100644 (file)
@@ -217,7 +217,7 @@ unsafe extern "C" fn fops_ioctl<T: MiscDevice>(
     // SAFETY: Ioctl calls can borrow the private data of the file.
     let device = unsafe { <T::Ptr as ForeignOwnable>::borrow(private) };
 
-    match T::ioctl(device, cmd as u32, arg as usize) {
+    match T::ioctl(device, cmd, arg as usize) {
         Ok(ret) => ret as c_long,
         Err(err) => err.to_errno() as c_long,
     }
@@ -234,7 +234,7 @@ unsafe extern "C" fn fops_compat_ioctl<T: MiscDevice>(
     // SAFETY: Ioctl calls can borrow the private data of the file.
     let device = unsafe { <T::Ptr as ForeignOwnable>::borrow(private) };
 
-    match T::compat_ioctl(device, cmd as u32, arg as usize) {
+    match T::compat_ioctl(device, cmd, arg as usize) {
         Ok(ret) => ret as c_long,
         Err(err) => err.to_errno() as c_long,
     }
This page took 0.047534 seconds and 4 git commands to generate.