-
Notifications
You must be signed in to change notification settings - Fork 56.9k
Comparing changes
Open a pull request
base repository: torvalds/linux
base: master
head repository: Rust-for-Linux/linux
compare: rust-next
- 14 commits
- 54 files changed
- 8 contributors
Commits on Jun 22, 2025
-
rust: enable
clippy::ptr_as_ptr
lintIn Rust 1.51.0, Clippy introduced the `ptr_as_ptr` lint [1]: > Though `as` casts between raw pointers are not terrible, > `pointer::cast` is safer because it cannot accidentally change the > pointer's mutability, nor cast the pointer to other types like `usize`. There are a few classes of changes required: - Modules generated by bindgen are marked `#[allow(clippy::ptr_as_ptr)]`. - Inferred casts (` as _`) are replaced with `.cast()`. - Ascribed casts (` as *... T`) are replaced with `.cast::<T>()`. - Multistep casts from references (` as *const _ as *const T`) are replaced with `core::ptr::from_ref(&x).cast()` with or without `::<T>` according to the previous rules. The `core::ptr::from_ref` call is required because `(x as *const _).cast::<T>()` results in inference failure. - Native literal C strings are replaced with `c_str!().as_char_ptr()`. - `*mut *mut T as _` is replaced with `let *mut *const T = (*mut *mut T)`.cast();` since pointer to pointer can be confusing. Apply these changes and enable the lint -- no functional change intended. Link: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_as_ptr [1] Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Boqun Feng <[email protected]> Signed-off-by: Tamir Duberstein <[email protected]> Acked-by: Viresh Kumar <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Acked-by: Tejun Heo <[email protected]> Acked-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Added `.cast()` for `opp`. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for fcad9bb - Browse repository at this point
Copy the full SHA fcad9bbView commit details -
rust: enable
clippy::ptr_cast_constness
lintIn Rust 1.72.0, Clippy introduced the `ptr_cast_constness` lint [1]: > Though `as` casts between raw pointers are not terrible, > `pointer::cast_mut` and `pointer::cast_const` are safer because they > cannot accidentally cast the pointer to another type. There are only 3 affected sites: - `*mut T as *const U as *mut U` becomes `(*mut T).cast()`. - `&self as *const Self as *mut Self` becomes `core::ptr::from_ref(self).cast_mut()`. - `*const T as *mut _` becommes `(*const T).cast_mut()`. Apply these changes and enable the lint -- no functional change intended. Link: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_cast_constness [1] Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Boqun Feng <[email protected]> Signed-off-by: Tamir Duberstein <[email protected]> Acked-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for d8c9e73 - Browse repository at this point
Copy the full SHA d8c9e73View commit details -
rust: enable
clippy::as_ptr_cast_mut
lintIn Rust 1.66.0, Clippy introduced the `as_ptr_cast_mut` lint [1]: > Since `as_ptr` takes a `&self`, the pointer won’t have write > permissions unless interior mutability is used, making it unlikely > that having it as a mutable pointer is correct. There is only one affected callsite, and the change amounts to replacing `as _` with `.cast_mut().cast()`. This doesn't change the semantics, but is more descriptive of what's going on. Apply this change and enable the lint -- no functional change intended. Link: https://rust-lang.github.io/rust-clippy/master/index.html#as_ptr_cast_mut [1] Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Boqun Feng <[email protected]> Signed-off-by: Tamir Duberstein <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Acked-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 23773bd - Browse repository at this point
Copy the full SHA 23773bdView commit details -
rust: enable
clippy::as_underscore
lintIn 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. Link: https://rust-lang.github.io/rust-clippy/master/index.html#as_underscore [1] Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Boqun Feng <[email protected]> Signed-off-by: Tamir Duberstein <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Acked-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Changed `isize` to `c_long`. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 5e30550 - Browse repository at this point
Copy the full SHA 5e30550View commit details -
rust: enable
clippy::cast_lossless
lintBefore Rust 1.29.0, Clippy introduced the `cast_lossless` lint [1]: > Rust’s `as` keyword will perform many kinds of conversions, including > silently lossy conversions. Conversion functions such as `i32::from` > will only perform lossless conversions. Using the conversion functions > prevents conversions from becoming silently lossy if the input types > ever change, and makes it clear for people reading the code that the > conversion is lossless. 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. Link: https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless [1] Suggested-by: Benno Lossin <[email protected]> Link: https://lore.kernel.org/all/[email protected]/ Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Boqun Feng <[email protected]> Signed-off-by: Tamir Duberstein <[email protected]> Acked-by: FUJITA Tomonori <[email protected]> Acked-by: Jocelyn Falempe <[email protected]> Acked-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for b7c8d7a - Browse repository at this point
Copy the full SHA b7c8d7aView commit details -
rust: enable
clippy::ref_as_ptr
lintIn Rust 1.78.0, Clippy introduced the `ref_as_ptr` lint [1]: > Using `as` casts may result in silently changing mutability or type. 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. Link: https://rust-lang.github.io/rust-clippy/master/index.html#ref_as_ptr [1] Suggested-by: Benno Lossin <[email protected]> Link: https://lore.kernel.org/all/[email protected]/ Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Boqun Feng <[email protected]> Signed-off-by: Tamir Duberstein <[email protected]> Acked-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for dc35ddc - Browse repository at this point
Copy the full SHA dc35ddcView commit details
Commits on Jun 23, 2025
-
rust: kunit: use crate-level mapping for
c_void
Remove `use core::ffi::c_void`, which shadows `kernel::ffi::c_void` brought in via `use crate::prelude::*`, to maintain consistency and centralize the abstraction. Since `kernel::ffi::c_void` is a straightforward re-export of `core::ffi::c_void`, both are functionally equivalent. However, using `kernel::ffi::c_void` improves consistency across the kernel's Rust code and provides a unified reference point in case the definition ever needs to change, even if such a change is unlikely. Reviewed-by: Benno Lossin <[email protected]> Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089/topic/x/near/520452733 Signed-off-by: Jesung Yang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 5d4ffc5 - Browse repository at this point
Copy the full SHA 5d4ffc5View commit details -
rust: list: replace unwrap() with ? in doctest examples
Using `unwrap()` in kernel doctests can cause panics on error and may give newcomers the mistaken impression that panicking is acceptable in kernel code. Replace all `.unwrap()` calls in `kernel::list` examples with `.ok_or(EINVAL)?` so that errors are properly propagated. Suggested-by: Miguel Ojeda <[email protected]> Link: Rust-for-Linux#1164 Reviewed-by: Benno Lossin <[email protected]> Signed-off-by: Albin Babu Varghese <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Reworded slightly. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for b61b009 - Browse repository at this point
Copy the full SHA b61b009View commit details -
rust: macros: remove
module!
's deprecatedauthor
keyCommit 38559da ("rust: module: introduce `authors` key") introduced a new `authors` key to support multiple module authors, while keeping the old `author` key for backward compatibility. Now that most in-tree modules have migrated to `authors`, remove: 1. The deprecated `author` key support from the module macro 2. Legacy `author` entries from remaining modules Signed-off-by: Guilherme Giacomo Simoes <[email protected]> Acked-by: Andreas Hindborg <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Acked-by: Danilo Krummrich <[email protected]> Acked-by: Viresh Kumar <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Reworded slightly. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for bfb9e46 - Browse repository at this point
Copy the full SHA bfb9e46View commit details -
rust: Use consistent "# Examples" heading style in rustdoc
Use a consistent `# Examples` heading in rustdoc across the codebase. Some modules previously used `## Examples` (even when they should be available as top-level headers), while others used `# Example`, which deviates from the preferred `# Examples` style. Suggested-by: Miguel Ojeda <[email protected]> Signed-off-by: Viresh Kumar <[email protected]> Acked-by: Benno Lossin <[email protected]> Link: https://lore.kernel.org/r/ddd5ce0ac20c99a72a4f1e4322d3de3911056922.1749545815.git.viresh.kumar@linaro.org Signed-off-by: Miguel Ojeda <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for b698508 - Browse repository at this point
Copy the full SHA b698508View commit details -
rust: io: avoid mentioning private fields in
IoMem
Removed reference to internal variables in the comment of `IoMem` This avoids using private variable names in public documentation. Suggested-by: Miguel Ojeda <[email protected]> Link: Rust-for-Linux#1167 Signed-off-by: Sai Vishnu M <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Reworded title and adjusted tags. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 0303584 - Browse repository at this point
Copy the full SHA 0303584View commit details
Commits on Jun 29, 2025
-
rust: rbtree: add RBTree::is_empty
In Rust Binder I need to be able to determine whether a red/black tree is empty. Thus, add a method for that operation to replace rbtree.iter().next().is_none() This is terrible, so add a method for this purpose. We do not add a RBTree::len method because computing the number of elements requires iterating the entire tree, but checking whether it is empty can be done cheaply. Signed-off-by: Alice Ryhl <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Adjusted title. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for fbcd4b7 - Browse repository at this point
Copy the full SHA fbcd4b7View commit details -
rust: revocable: document why &T is not used in RevocableGuard
When a reference appears in a function argument, the reference is assumed to be valid for the entire duration of that function call; this is called a stack protector [1]. Because of that, custom pointer types whose destructor may invalidate the pointee (i.e. they are more similar to Box<T> than &T) cannot internally use a reference, and must instead use a raw pointer. This issue is something that is often missed during unsafe review. For examples, see [2] and [3]. To ensure that people don't try to simplify RevocableGuard by changing the raw pointer to a reference, add a comment to that effect. Link: https://perso.crans.org/vanille/treebor/protectors.html [1] Link: https://users.rust-lang.org/t/unsafe-code-review-semi-owning-weak-rwlock-t-guard/95706 [2] Link: https://lore.kernel.org/all/[email protected]/ [3] Signed-off-by: Alice Ryhl <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Adjusted title. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for d6763e0 - Browse repository at this point
Copy the full SHA d6763e0View commit details
Commits on Jul 3, 2025
-
rust: sync: implement
Borrow
andBorrowMut
forArc
typesImplement `Borrow<T>` and `BorrowMut<T>` for `UniqueArc<T>`, and `Borrow<T>` for `Arc<T>`. This allows these containers to be used in generic APIs asking for types implementing those traits. `T` and `&mut T` also implement those traits allowing users to use either owned, shared or borrowed values. `ForeignOwnable` makes a call to its own `borrow` method which must be disambiguated. Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Signed-off-by: Alexandre Courbot <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 2009a2d - Browse repository at this point
Copy the full SHA 2009a2dView commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff master...rust-next