Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Low] Un-updated AlwaysRefCounted trait implementations cause conditional 
compilation and rustdoc test errors.
--

commit 5db284043a909f35f9aed5c1467a5f9cf863972d
Author: Trevor Chan <[email protected]>
rust: aref: make `AlwaysRefCounted::inc_ref` an associated function

This commit changes the AlwaysRefCounted::inc_ref function from a method
to an associated function to prevent accidental calls. It updates the
implementors of this trait to reflect this change.

Link: https://github.com/Rust-for-Linux/linux/issues/1177

> diff --git a/rust/kernel/sync/aref.rs b/rust/kernel/sync/aref.rs
> index b721b2e00b986..2ae2130d5bb1d 100644
> --- a/rust/kernel/sync/aref.rs
> +++ b/rust/kernel/sync/aref.rs
> @@ -44,7 +44,10 @@
>  /// alive.)
>  pub unsafe trait AlwaysRefCounted {
>      /// Increments the reference count on the object.
> -    fn inc_ref(&self);
> +    ///
> +    /// This function should not be called accidentally; a type might 
> declare their own `inc_ref`
> +    /// function and it shouldn't be confused with this one.
> +    fn inc_ref(obj: &Self);

[Severity: Low]
Will this change break the build for conditionally compiled modules and
rustdoc tests that still use the old method signature?

When compiling with CONFIG_RUST_DRM_GPUVM, CONFIG_PM_OPP, or
CONFIG_RUST_PWM_ABSTRACTIONS enabled, it appears this will result in
compiler error E0185 because the following implementations were not updated:

rust/kernel/drm/gpuvm/mod.rs:
unsafe impl<T: DriverGpuVm> AlwaysRefCounted for GpuVm<T> {
    fn inc_ref(&self) {

rust/kernel/drm/gpuvm/vm_bo.rs:
unsafe impl<T: DriverGpuVm> AlwaysRefCounted for GpuVmBo<T> {
    fn inc_ref(&self) {

rust/kernel/opp.rs:
unsafe impl AlwaysRefCounted for OPP {
    #[inline]
    fn inc_ref(&self) {

rust/kernel/pwm.rs:
unsafe impl<T: PwmOps> AlwaysRefCounted for Chip<T> {
    #[inline]
    fn inc_ref(&self) {

Additionally, a rustdoc test in rust/kernel/sync/aref.rs for ARef::into_raw
still implements it using the old signature:

    /// unsafe impl AlwaysRefCounted for Empty {
    ///     fn inc_ref(&self) {}

Should these implementations be updated to use fn inc_ref(obj: &Self) to
match the new trait definition?

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to