History

rust: enable `clippy::as_underscore` lint

In Rust 1.63.0, Clippy introduced the `as_underscore` lint [1]: > The conversion might include lossy conversion or a dangerous cast that > might go undetected due to the type being inferred. > > The lint is allowed by default as using `_` is less wordy than always > specifying the type. Always specifying the type is especially helpful in function call contexts where the inferred type may change at a distance. Specifying the type also allows Clippy to spot more cases of `useless_conversion`. The primary downside is the need to specify the type in trivial getters. There are 4 such functions: 3 have become slightly less ergonomic, 1 was revealed to be a `useless_conversion`. While this doesn't eliminate unchecked `as` conversions, it makes such conversions easier to scrutinize. It also has the slight benefit of removing a degree of freedom on which to bikeshed. Thus apply the changes and enable the lint -- no functional change intended.

Tamir Duberstein committed 1 year ago

Commit 5e305501 parent 23773bd16 files · +70 −60Browse files

Unified · Split

16 files
  1. Makefile +1 −0
  2. drivers/gpu/nova-core/driver.rs +1 −1
  3. rust/kernel/block/mq/operations.rs +1 −1
  4. rust/kernel/block/mq/request.rs +6 −1
  5. rust/kernel/device_id.rs +1 −1
  6. rust/kernel/devres.rs +7 −6
  7. rust/kernel/dma.rs +1 −1
  8. rust/kernel/drm/device.rs +1 −1
  9. rust/kernel/error.rs +1 −1
  10. rust/kernel/io.rs +9 −9
  11. rust/kernel/miscdevice.rs +1 −1
  12. rust/kernel/mm/virt.rs +26 −26
  13. rust/kernel/of.rs +3 −3
  14. rust/kernel/pci.rs +6 −3
  15. rust/kernel/str.rs +4 −4
  16. rust/kernel/workqueue.rs +1 −1
Makefile+1−0
@@ -480,6 +480,7 @@ export rust_common_flags := --edition=2021 \ · 479 unmodified lines
480 -Wunreachable_pub \480 -Wunreachable_pub \
481 -Wclippy::all \481 -Wclippy::all \
482 -Wclippy::as_ptr_cast_mut \482 -Wclippy::as_ptr_cast_mut \
483 -Wclippy::as_underscore \
483 -Wclippy::ignored_unit_patterns \484 -Wclippy::ignored_unit_patterns \
484 -Wclippy::mut_mut \485 -Wclippy::mut_mut \
485 -Wclippy::needless_bitwise_bool \486 -Wclippy::needless_bitwise_bool \
drivers/gpu/nova-core/driver.rs+1−1
@@ -19,7 +19,7 @@ kernel::pci_device_table!( · 18 unmodified lines
19 MODULE_PCI_TABLE,19 MODULE_PCI_TABLE,
20 <NovaCore as pci::Driver>::IdInfo,20 <NovaCore as pci::Driver>::IdInfo,
21 [(21 [(
22 pci::DeviceId::from_id(bindings::PCI_VENDOR_ID_NVIDIA, bindings::PCI_ANY_ID as _),22 pci::DeviceId::from_id(bindings::PCI_VENDOR_ID_NVIDIA, bindings::PCI_ANY_ID as u32),
23 ()23 ()
24 )]24 )]
25);25);
rust/kernel/block/mq/operations.rs+1−1
@@ -101,7 +101,7 @@ impl<T: Operations> OperationsVTable<T> { · 100 unmodified lines
101 if let Err(e) = ret {101 if let Err(e) = ret {
102 e.to_blk_status()102 e.to_blk_status()
103 } else {103 } else {
104 bindings::BLK_STS_OK as _104 bindings::BLK_STS_OK as bindings::blk_status_t
105 }105 }
106 }106 }
107 107
rust/kernel/block/mq/request.rs+6−1
@@ -125,7 +125,12 @@ impl<T: Operations> Request<T> { · 124 unmodified lines
125 // success of the call to `try_set_end` guarantees that there are no125 // success of the call to `try_set_end` guarantees that there are no
126 // `ARef`s pointing to this request. Therefore it is safe to hand it126 // `ARef`s pointing to this request. Therefore it is safe to hand it
127 // back to the block layer.127 // back to the block layer.
128 unsafe { bindings::blk_mq_end_request(request_ptr, bindings::BLK_STS_OK as _) };128 unsafe {
129 bindings::blk_mq_end_request(
130 request_ptr,
131 bindings::BLK_STS_OK as bindings::blk_status_t,
132 )
133 };
129 134
130 Ok(())135 Ok(())
131 }136 }
rust/kernel/device_id.rs+1−1
@@ -82,7 +82,7 @@ impl<T: RawDeviceId, U, const N: usize> IdArray<T, U, N> { · 81 unmodified lines
82 unsafe {82 unsafe {
83 raw_ids[i]83 raw_ids[i]
84 .as_mut_ptr()84 .as_mut_ptr()
85 .byte_offset(T::DRIVER_DATA_OFFSET as _)85 .byte_add(T::DRIVER_DATA_OFFSET)
86 .cast::<usize>()86 .cast::<usize>()
87 .write(i);87 .write(i);
88 }88 }
rust/kernel/devres.rs+7−6
@@ -61,19 +61,19 @@ struct DevresInner<T> { · 60 unmodified lines
61/// unsafe fn new(paddr: usize) -> Result<Self>{61/// unsafe fn new(paddr: usize) -> Result<Self>{
62/// // SAFETY: By the safety requirements of this function [`paddr`, `paddr` + `SIZE`) is62/// // SAFETY: By the safety requirements of this function [`paddr`, `paddr` + `SIZE`) is
63/// // valid for `ioremap`.63/// // valid for `ioremap`.
64/// let addr = unsafe { bindings::ioremap(paddr as _, SIZE as _) };64/// let addr = unsafe { bindings::ioremap(paddr as bindings::phys_addr_t, SIZE) };
65/// if addr.is_null() {65/// if addr.is_null() {
66/// return Err(ENOMEM);66/// return Err(ENOMEM);
67/// }67/// }
68///68///
69/// Ok(IoMem(IoRaw::new(addr as _, SIZE)?))69/// Ok(IoMem(IoRaw::new(addr as usize, SIZE)?))
70/// }70/// }
71/// }71/// }
72///72///
73/// impl<const SIZE: usize> Drop for IoMem<SIZE> {73/// impl<const SIZE: usize> Drop for IoMem<SIZE> {
74/// fn drop(&mut self) {74/// fn drop(&mut self) {
75/// // SAFETY: `self.0.addr()` is guaranteed to be properly mapped by `Self::new`.75/// // SAFETY: `self.0.addr()` is guaranteed to be properly mapped by `Self::new`.
76/// unsafe { bindings::iounmap(self.0.addr() as _); };76/// unsafe { bindings::iounmap(self.0.addr() as *mut c_void); };
77/// }77/// }
78/// }78/// }
79///79///
@@ -115,8 +115,9 @@ impl<T> DevresInner<T> { · 35 unmodified lines
115 115
116 // SAFETY: `devm_add_action` guarantees to call `Self::devres_callback` once `dev` is116 // SAFETY: `devm_add_action` guarantees to call `Self::devres_callback` once `dev` is
117 // detached.117 // detached.
118 let ret =118 let ret = unsafe {
119 unsafe { bindings::devm_add_action(dev.as_raw(), Some(inner.callback), data as _) };119 bindings::devm_add_action(dev.as_raw(), Some(inner.callback), data.cast_mut().cast())
120 };
120 121
121 if ret != 0 {122 if ret != 0 {
122 // SAFETY: We just created another reference to `inner` in order to pass it to123 // SAFETY: We just created another reference to `inner` in order to pass it to
@@ -130,7 +131,7 @@ impl<T> DevresInner<T> { · 7 unmodified lines
130 }131 }
131 132
132 fn as_ptr(&self) -> *const Self {133 fn as_ptr(&self) -> *const Self {
133 self as _134 self
134 }135 }
135 136
136 fn remove_action(this: &Arc<Self>) -> bool {137 fn remove_action(this: &Arc<Self>) -> bool {
rust/kernel/dma.rs+1−1
@@ -38,7 +38,7 @@ pub struct Attrs(u32); · 37 unmodified lines
38impl Attrs {38impl Attrs {
39 /// Get the raw representation of this attribute.39 /// Get the raw representation of this attribute.
40 pub(crate) fn as_raw(self) -> crate::ffi::c_ulong {40 pub(crate) fn as_raw(self) -> crate::ffi::c_ulong {
41 self.0 as _41 self.0 as crate::ffi::c_ulong
42 }42 }
43 43
44 /// Check whether `flags` is contained in `self`.44 /// Check whether `flags` is contained in `self`.
rust/kernel/drm/device.rs+1−1
@@ -89,7 +89,7 @@ impl<T: drm::Driver> Device<T> { · 88 unmodified lines
89 driver_features: drm::driver::FEAT_GEM,89 driver_features: drm::driver::FEAT_GEM,
90 ioctls: T::IOCTLS.as_ptr(),90 ioctls: T::IOCTLS.as_ptr(),
91 num_ioctls: T::IOCTLS.len() as i32,91 num_ioctls: T::IOCTLS.len() as i32,
92 fops: &Self::GEM_FOPS as _,92 fops: &Self::GEM_FOPS,
93 };93 };
94 94
95 const GEM_FOPS: bindings::file_operations = drm::gem::create_fops();95 const GEM_FOPS: bindings::file_operations = drm::gem::create_fops();
rust/kernel/error.rs+1−1
@@ -153,7 +153,7 @@ impl Error { · 152 unmodified lines
153 /// Returns the error encoded as a pointer.153 /// Returns the error encoded as a pointer.
154 pub fn to_ptr<T>(self) -> *mut T {154 pub fn to_ptr<T>(self) -> *mut T {
155 // SAFETY: `self.0` is a valid error due to its invariant.155 // SAFETY: `self.0` is a valid error due to its invariant.
156 unsafe { bindings::ERR_PTR(self.0.get() as _).cast() }156 unsafe { bindings::ERR_PTR(self.0.get() as crate::ffi::c_long).cast() }
157 }157 }
158 158
159 /// Returns a string representing the error, if one exists.159 /// Returns a string representing the error, if one exists.
rust/kernel/io.rs+9−9
@@ -5,7 +5,7 @@ · 4 unmodified lines
5//! C header: [`include/asm-generic/io.h`](srctree/include/asm-generic/io.h)5//! C header: [`include/asm-generic/io.h`](srctree/include/asm-generic/io.h)
6 6
7use crate::error::{code::EINVAL, Result};7use crate::error::{code::EINVAL, Result};
8use crate::{bindings, build_assert};8use crate::{bindings, build_assert, ffi::c_void};
9 9
10/// Raw representation of an MMIO region.10/// Raw representation of an MMIO region.
11///11///
@@ -56,7 +56,7 @@ impl<const SIZE: usize> IoRaw<SIZE> { · 44 unmodified lines
56/// # Examples56/// # Examples
57///57///
58/// ```no_run58/// ```no_run
59/// # use kernel::{bindings, io::{Io, IoRaw}};59/// # use kernel::{bindings, ffi::c_void, io::{Io, IoRaw}};
60/// # use core::ops::Deref;60/// # use core::ops::Deref;
61///61///
62/// // See also [`pci::Bar`] for a real example.62/// // See also [`pci::Bar`] for a real example.
@@ -70,19 +70,19 @@ impl<const SIZE: usize> IoRaw<SIZE> { · 7 unmodified lines
70/// unsafe fn new(paddr: usize) -> Result<Self>{70/// unsafe fn new(paddr: usize) -> Result<Self>{
71/// // SAFETY: By the safety requirements of this function [`paddr`, `paddr` + `SIZE`) is71/// // SAFETY: By the safety requirements of this function [`paddr`, `paddr` + `SIZE`) is
72/// // valid for `ioremap`.72/// // valid for `ioremap`.
73/// let addr = unsafe { bindings::ioremap(paddr as _, SIZE as _) };73/// let addr = unsafe { bindings::ioremap(paddr as bindings::phys_addr_t, SIZE) };
74/// if addr.is_null() {74/// if addr.is_null() {
75/// return Err(ENOMEM);75/// return Err(ENOMEM);
76/// }76/// }
77///77///
78/// Ok(IoMem(IoRaw::new(addr as _, SIZE)?))78/// Ok(IoMem(IoRaw::new(addr as usize, SIZE)?))
79/// }79/// }
80/// }80/// }
81///81///
82/// impl<const SIZE: usize> Drop for IoMem<SIZE> {82/// impl<const SIZE: usize> Drop for IoMem<SIZE> {
83/// fn drop(&mut self) {83/// fn drop(&mut self) {
84/// // SAFETY: `self.0.addr()` is guaranteed to be properly mapped by `Self::new`.84/// // SAFETY: `self.0.addr()` is guaranteed to be properly mapped by `Self::new`.
85/// unsafe { bindings::iounmap(self.0.addr() as _); };85/// unsafe { bindings::iounmap(self.0.addr() as *mut c_void); };
86/// }86/// }
87/// }87/// }
88///88///
@@ -119,7 +119,7 @@ macro_rules! define_read { · 30 unmodified lines
119 let addr = self.io_addr_assert::<$type_name>(offset);119 let addr = self.io_addr_assert::<$type_name>(offset);
120 120
121 // SAFETY: By the type invariant `addr` is a valid address for MMIO operations.121 // SAFETY: By the type invariant `addr` is a valid address for MMIO operations.
122 unsafe { bindings::$c_fn(addr as _) }122 unsafe { bindings::$c_fn(addr as *const c_void) }
123 }123 }
124 124
125 /// Read IO data from a given offset.125 /// Read IO data from a given offset.
@@ -131,7 +131,7 @@ macro_rules! define_read { · 5 unmodified lines
131 let addr = self.io_addr::<$type_name>(offset)?;131 let addr = self.io_addr::<$type_name>(offset)?;
132 132
133 // SAFETY: By the type invariant `addr` is a valid address for MMIO operations.133 // SAFETY: By the type invariant `addr` is a valid address for MMIO operations.
134 Ok(unsafe { bindings::$c_fn(addr as _) })134 Ok(unsafe { bindings::$c_fn(addr as *const c_void) })
135 }135 }
136 };136 };
137}137}
@@ -148,7 +148,7 @@ macro_rules! define_write { · 10 unmodified lines
148 let addr = self.io_addr_assert::<$type_name>(offset);148 let addr = self.io_addr_assert::<$type_name>(offset);
149 149
150 // SAFETY: By the type invariant `addr` is a valid address for MMIO operations.150 // SAFETY: By the type invariant `addr` is a valid address for MMIO operations.
151 unsafe { bindings::$c_fn(value, addr as _, ) }151 unsafe { bindings::$c_fn(value, addr as *mut c_void) }
152 }152 }
153 153
154 /// Write IO data from a given offset.154 /// Write IO data from a given offset.
@@ -160,7 +160,7 @@ macro_rules! define_write { · 5 unmodified lines
160 let addr = self.io_addr::<$type_name>(offset)?;160 let addr = self.io_addr::<$type_name>(offset)?;
161 161
162 // SAFETY: By the type invariant `addr` is a valid address for MMIO operations.162 // SAFETY: By the type invariant `addr` is a valid address for MMIO operations.
163 unsafe { bindings::$c_fn(value, addr as _) }163 unsafe { bindings::$c_fn(value, addr as *mut c_void) }
164 Ok(())164 Ok(())
165 }165 }
166 };166 };
rust/kernel/miscdevice.rs+1−1
@@ -34,7 +34,7 @@ impl MiscDeviceOptions { · 33 unmodified lines
34 pub const fn into_raw<T: MiscDevice>(self) -> bindings::miscdevice {34 pub const fn into_raw<T: MiscDevice>(self) -> bindings::miscdevice {
35 // SAFETY: All zeros is valid for this C type.35 // SAFETY: All zeros is valid for this C type.
36 let mut result: bindings::miscdevice = unsafe { MaybeUninit::zeroed().assume_init() };36 let mut result: bindings::miscdevice = unsafe { MaybeUninit::zeroed().assume_init() };
37 result.minor = bindings::MISC_DYNAMIC_MINOR as _;37 result.minor = bindings::MISC_DYNAMIC_MINOR as ffi::c_int;
38 result.name = self.name.as_char_ptr();38 result.name = self.name.as_char_ptr();
39 result.fops = MiscdeviceVTable::<T>::build();39 result.fops = MiscdeviceVTable::<T>::build();
40 result40 result
rust/kernel/mm/virt.rs+26−26
@@ -392,80 +392,80 @@ pub mod flags { · 391 unmodified lines
392 use crate::bindings;392 use crate::bindings;
393 393
394 /// No flags are set.394 /// No flags are set.
395 pub const NONE: vm_flags_t = bindings::VM_NONE as _;395 pub const NONE: vm_flags_t = bindings::VM_NONE as vm_flags_t;
396 396
397 /// Mapping allows reads.397 /// Mapping allows reads.
398 pub const READ: vm_flags_t = bindings::VM_READ as _;398 pub const READ: vm_flags_t = bindings::VM_READ as vm_flags_t;
399 399
400 /// Mapping allows writes.400 /// Mapping allows writes.
401 pub const WRITE: vm_flags_t = bindings::VM_WRITE as _;401 pub const WRITE: vm_flags_t = bindings::VM_WRITE as vm_flags_t;
402 402
403 /// Mapping allows execution.403 /// Mapping allows execution.
404 pub const EXEC: vm_flags_t = bindings::VM_EXEC as _;404 pub const EXEC: vm_flags_t = bindings::VM_EXEC as vm_flags_t;
405 405
406 /// Mapping is shared.406 /// Mapping is shared.
407 pub const SHARED: vm_flags_t = bindings::VM_SHARED as _;407 pub const SHARED: vm_flags_t = bindings::VM_SHARED as vm_flags_t;
408 408
409 /// Mapping may be updated to allow reads.409 /// Mapping may be updated to allow reads.
410 pub const MAYREAD: vm_flags_t = bindings::VM_MAYREAD as _;410 pub const MAYREAD: vm_flags_t = bindings::VM_MAYREAD as vm_flags_t;
411 411
412 /// Mapping may be updated to allow writes.412 /// Mapping may be updated to allow writes.
413 pub const MAYWRITE: vm_flags_t = bindings::VM_MAYWRITE as _;413 pub const MAYWRITE: vm_flags_t = bindings::VM_MAYWRITE as vm_flags_t;
414 414
415 /// Mapping may be updated to allow execution.415 /// Mapping may be updated to allow execution.
416 pub const MAYEXEC: vm_flags_t = bindings::VM_MAYEXEC as _;416 pub const MAYEXEC: vm_flags_t = bindings::VM_MAYEXEC as vm_flags_t;
417 417
418 /// Mapping may be updated to be shared.418 /// Mapping may be updated to be shared.
419 pub const MAYSHARE: vm_flags_t = bindings::VM_MAYSHARE as _;419 pub const MAYSHARE: vm_flags_t = bindings::VM_MAYSHARE as vm_flags_t;
420 420
421 /// Page-ranges managed without `struct page`, just pure PFN.421 /// Page-ranges managed without `struct page`, just pure PFN.
422 pub const PFNMAP: vm_flags_t = bindings::VM_PFNMAP as _;422 pub const PFNMAP: vm_flags_t = bindings::VM_PFNMAP as vm_flags_t;
423 423
424 /// Memory mapped I/O or similar.424 /// Memory mapped I/O or similar.
425 pub const IO: vm_flags_t = bindings::VM_IO as _;425 pub const IO: vm_flags_t = bindings::VM_IO as vm_flags_t;
426 426
427 /// Do not copy this vma on fork.427 /// Do not copy this vma on fork.
428 pub const DONTCOPY: vm_flags_t = bindings::VM_DONTCOPY as _;428 pub const DONTCOPY: vm_flags_t = bindings::VM_DONTCOPY as vm_flags_t;
429 429
430 /// Cannot expand with mremap().430 /// Cannot expand with mremap().
431 pub const DONTEXPAND: vm_flags_t = bindings::VM_DONTEXPAND as _;431 pub const DONTEXPAND: vm_flags_t = bindings::VM_DONTEXPAND as vm_flags_t;
432 432
433 /// Lock the pages covered when they are faulted in.433 /// Lock the pages covered when they are faulted in.
434 pub const LOCKONFAULT: vm_flags_t = bindings::VM_LOCKONFAULT as _;434 pub const LOCKONFAULT: vm_flags_t = bindings::VM_LOCKONFAULT as vm_flags_t;
435 435
436 /// Is a VM accounted object.436 /// Is a VM accounted object.
437 pub const ACCOUNT: vm_flags_t = bindings::VM_ACCOUNT as _;437 pub const ACCOUNT: vm_flags_t = bindings::VM_ACCOUNT as vm_flags_t;
438 438
439 /// Should the VM suppress accounting.439 /// Should the VM suppress accounting.
440 pub const NORESERVE: vm_flags_t = bindings::VM_NORESERVE as _;440 pub const NORESERVE: vm_flags_t = bindings::VM_NORESERVE as vm_flags_t;
441 441
442 /// Huge TLB Page VM.442 /// Huge TLB Page VM.
443 pub const HUGETLB: vm_flags_t = bindings::VM_HUGETLB as _;443 pub const HUGETLB: vm_flags_t = bindings::VM_HUGETLB as vm_flags_t;
444 444
445 /// Synchronous page faults. (DAX-specific)445 /// Synchronous page faults. (DAX-specific)
446 pub const SYNC: vm_flags_t = bindings::VM_SYNC as _;446 pub const SYNC: vm_flags_t = bindings::VM_SYNC as vm_flags_t;
447 447
448 /// Architecture-specific flag.448 /// Architecture-specific flag.
449 pub const ARCH_1: vm_flags_t = bindings::VM_ARCH_1 as _;449 pub const ARCH_1: vm_flags_t = bindings::VM_ARCH_1 as vm_flags_t;
450 450
451 /// Wipe VMA contents in child on fork.451 /// Wipe VMA contents in child on fork.
452 pub const WIPEONFORK: vm_flags_t = bindings::VM_WIPEONFORK as _;452 pub const WIPEONFORK: vm_flags_t = bindings::VM_WIPEONFORK as vm_flags_t;
453 453
454 /// Do not include in the core dump.454 /// Do not include in the core dump.
455 pub const DONTDUMP: vm_flags_t = bindings::VM_DONTDUMP as _;455 pub const DONTDUMP: vm_flags_t = bindings::VM_DONTDUMP as vm_flags_t;
456 456
457 /// Not soft dirty clean area.457 /// Not soft dirty clean area.
458 pub const SOFTDIRTY: vm_flags_t = bindings::VM_SOFTDIRTY as _;458 pub const SOFTDIRTY: vm_flags_t = bindings::VM_SOFTDIRTY as vm_flags_t;
459 459
460 /// Can contain `struct page` and pure PFN pages.460 /// Can contain `struct page` and pure PFN pages.
461 pub const MIXEDMAP: vm_flags_t = bindings::VM_MIXEDMAP as _;461 pub const MIXEDMAP: vm_flags_t = bindings::VM_MIXEDMAP as vm_flags_t;
462 462
463 /// MADV_HUGEPAGE marked this vma.463 /// MADV_HUGEPAGE marked this vma.
464 pub const HUGEPAGE: vm_flags_t = bindings::VM_HUGEPAGE as _;464 pub const HUGEPAGE: vm_flags_t = bindings::VM_HUGEPAGE as vm_flags_t;
465 465
466 /// MADV_NOHUGEPAGE marked this vma.466 /// MADV_NOHUGEPAGE marked this vma.
467 pub const NOHUGEPAGE: vm_flags_t = bindings::VM_NOHUGEPAGE as _;467 pub const NOHUGEPAGE: vm_flags_t = bindings::VM_NOHUGEPAGE as vm_flags_t;
468 468
469 /// KSM may merge identical pages.469 /// KSM may merge identical pages.
470 pub const MERGEABLE: vm_flags_t = bindings::VM_MERGEABLE as _;470 pub const MERGEABLE: vm_flags_t = bindings::VM_MERGEABLE as vm_flags_t;
471}471}
rust/kernel/of.rs+3−3
@@ -22,7 +22,7 @@ unsafe impl RawDeviceId for DeviceId { · 21 unmodified lines
22 const DRIVER_DATA_OFFSET: usize = core::mem::offset_of!(bindings::of_device_id, data);22 const DRIVER_DATA_OFFSET: usize = core::mem::offset_of!(bindings::of_device_id, data);
23 23
24 fn index(&self) -> usize {24 fn index(&self) -> usize {
25 self.0.data as _25 self.0.data as usize
26 }26 }
27}27}
28 28
@@ -34,10 +34,10 @@ impl DeviceId { · 5 unmodified lines
34 // SAFETY: FFI type is valid to be zero-initialized.34 // SAFETY: FFI type is valid to be zero-initialized.
35 let mut of: bindings::of_device_id = unsafe { core::mem::zeroed() };35 let mut of: bindings::of_device_id = unsafe { core::mem::zeroed() };
36 36
37 // TODO: Use `clone_from_slice` once the corresponding types do match.37 // TODO: Use `copy_from_slice` once stabilized for `const`.
38 let mut i = 0;38 let mut i = 0;
39 while i < src.len() {39 while i < src.len() {
40 of.compatible[i] = src[i] as _;40 of.compatible[i] = src[i];
41 i += 1;41 i += 1;
42 }42 }
43 43
rust/kernel/pci.rs+6−3
@@ -171,7 +171,7 @@ unsafe impl RawDeviceId for DeviceId { · 170 unmodified lines
171 const DRIVER_DATA_OFFSET: usize = core::mem::offset_of!(bindings::pci_device_id, driver_data);171 const DRIVER_DATA_OFFSET: usize = core::mem::offset_of!(bindings::pci_device_id, driver_data);
172 172
173 fn index(&self) -> usize {173 fn index(&self) -> usize {
174 self.0.driver_data as _174 self.0.driver_data
175 }175 }
176}176}
177 177
@@ -206,7 +206,10 @@ macro_rules! pci_device_table { · 28 unmodified lines
206/// MODULE_PCI_TABLE,206/// MODULE_PCI_TABLE,
207/// <MyDriver as pci::Driver>::IdInfo,207/// <MyDriver as pci::Driver>::IdInfo,
208/// [208/// [
209/// (pci::DeviceId::from_id(bindings::PCI_VENDOR_ID_REDHAT, bindings::PCI_ANY_ID as _), ())209/// (
210/// pci::DeviceId::from_id(bindings::PCI_VENDOR_ID_REDHAT, bindings::PCI_ANY_ID as u32),
211/// (),
212/// )
210/// ]213/// ]
211/// );214/// );
212///215///
@@ -330,7 +333,7 @@ impl<const SIZE: usize> Bar<SIZE> { · 117 unmodified lines
330 // `ioptr` is valid by the safety requirements.333 // `ioptr` is valid by the safety requirements.
331 // `num` is valid by the safety requirements.334 // `num` is valid by the safety requirements.
332 unsafe {335 unsafe {
333 bindings::pci_iounmap(pdev.as_raw(), ioptr as _);336 bindings::pci_iounmap(pdev.as_raw(), ioptr as *mut kernel::ffi::c_void);
334 bindings::pci_release_region(pdev.as_raw(), num);337 bindings::pci_release_region(pdev.as_raw(), num);
335 }338 }
336 }339 }
rust/kernel/str.rs+4−4
@@ -728,9 +728,9 @@ impl RawFormatter { · 727 unmodified lines
728 pub(crate) unsafe fn from_ptrs(pos: *mut u8, end: *mut u8) -> Self {728 pub(crate) unsafe fn from_ptrs(pos: *mut u8, end: *mut u8) -> Self {
729 // INVARIANT: The safety requirements guarantee the type invariants.729 // INVARIANT: The safety requirements guarantee the type invariants.
730 Self {730 Self {
731 beg: pos as _,731 beg: pos as usize,
732 pos: pos as _,732 pos: pos as usize,
733 end: end as _,733 end: end as usize,
734 }734 }
735 }735 }
736 736
@@ -755,7 +755,7 @@ impl RawFormatter { · 18 unmodified lines
755 ///755 ///
756 /// N.B. It may point to invalid memory.756 /// N.B. It may point to invalid memory.
757 pub(crate) fn pos(&self) -> *mut u8 {757 pub(crate) fn pos(&self) -> *mut u8 {
758 self.pos as _758 self.pos as *mut u8
759 }759 }
760 760
761 /// Returns the number of bytes written to the formatter.761 /// Returns the number of bytes written to the formatter.
rust/kernel/workqueue.rs+1−1
@@ -198,7 +198,7 @@ impl Queue { · 197 unmodified lines
198 unsafe {198 unsafe {
199 w.__enqueue(move |work_ptr| {199 w.__enqueue(move |work_ptr| {
200 bindings::queue_work_on(200 bindings::queue_work_on(
201 bindings::wq_misc_consts_WORK_CPU_UNBOUND as _,201 bindings::wq_misc_consts_WORK_CPU_UNBOUND as ffi::c_int,
202 queue_ptr,202 queue_ptr,
203 work_ptr,203 work_ptr,
204 )204 )

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t