Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: torvalds/linux
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: Rust-for-Linux/linux
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: rust-next
Choose a head ref
  • 14 commits
  • 54 files changed
  • 8 contributors

Commits on Jun 22, 2025

  1. rust: enable clippy::ptr_as_ptr lint

    In 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]>
    tamird authored and ojeda committed Jun 22, 2025
    Configuration menu
    Copy the full SHA
    fcad9bb View commit details
    Browse the repository at this point in the history
  2. rust: enable clippy::ptr_cast_constness lint

    In 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]>
    tamird authored and ojeda committed Jun 22, 2025
    Configuration menu
    Copy the full SHA
    d8c9e73 View commit details
    Browse the repository at this point in the history
  3. rust: enable clippy::as_ptr_cast_mut lint

    In 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]>
    tamird authored and ojeda committed Jun 22, 2025
    Configuration menu
    Copy the full SHA
    23773bd View commit details
    Browse the repository at this point in the history
  4. 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.
    
    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]>
    tamird authored and ojeda committed Jun 22, 2025
    Configuration menu
    Copy the full SHA
    5e30550 View commit details
    Browse the repository at this point in the history
  5. rust: enable clippy::cast_lossless lint

    Before 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]>
    tamird authored and ojeda committed Jun 22, 2025
    Configuration menu
    Copy the full SHA
    b7c8d7a View commit details
    Browse the repository at this point in the history
  6. rust: enable clippy::ref_as_ptr lint

    In 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]>
    tamird authored and ojeda committed Jun 22, 2025
    Configuration menu
    Copy the full SHA
    dc35ddc View commit details
    Browse the repository at this point in the history

Commits on Jun 23, 2025

  1. 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]>
    J3m3 authored and ojeda committed Jun 23, 2025
    Configuration menu
    Copy the full SHA
    5d4ffc5 View commit details
    Browse the repository at this point in the history
  2. 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]>
    albus-droid authored and ojeda committed Jun 23, 2025
    Configuration menu
    Copy the full SHA
    b61b009 View commit details
    Browse the repository at this point in the history
  3. rust: macros: remove module!'s deprecated author key

    Commit 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]>
    GuilhermeGiacomoSimoes authored and ojeda committed Jun 23, 2025
    Configuration menu
    Copy the full SHA
    bfb9e46 View commit details
    Browse the repository at this point in the history
  4. 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]>
    vireshk authored and ojeda committed Jun 23, 2025
    Configuration menu
    Copy the full SHA
    b698508 View commit details
    Browse the repository at this point in the history
  5. 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]>
    saivishnu725 authored and ojeda committed Jun 23, 2025
    Configuration menu
    Copy the full SHA
    0303584 View commit details
    Browse the repository at this point in the history

Commits on Jun 29, 2025

  1. 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]>
    Darksonn authored and ojeda committed Jun 29, 2025
    Configuration menu
    Copy the full SHA
    fbcd4b7 View commit details
    Browse the repository at this point in the history
  2. 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]>
    Darksonn authored and ojeda committed Jun 29, 2025
    Configuration menu
    Copy the full SHA
    d6763e0 View commit details
    Browse the repository at this point in the history

Commits on Jul 3, 2025

  1. rust: sync: implement Borrow and BorrowMut for Arc types

    Implement `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]>
    Gnurou authored and ojeda committed Jul 3, 2025
    Configuration menu
    Copy the full SHA
    2009a2d View commit details
    Browse the repository at this point in the history
Loading