From: sashiko-bot@kernel.org
To: "Trevor Chan" <trev@trevrosa.dev>
Cc: dri-devel@lists.freedesktop.org, ojeda@kernel.org,
linux-pci@vger.kernel.org
Subject: Re: [PATCH v6] rust: aref: make `AlwaysRefCounted::inc_ref` an associated function
Date: Sun, 28 Jun 2026 09:58:12 +0000 [thread overview]
Message-ID: <20260628095813.2D6A31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260628095132.47753-1-trev@trevrosa.dev>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] The `inc_ref` function body for `Chip<T>` still uses the undefined `self` identifier instead of the new `obj` parameter.
- [Low] Safety comments in multiple files still reference `self` instead of the renamed `obj` parameter.
--
commit 26c2b1b363c343fdcaf27bbc75d1dde6b5b4dbfc
Author: Trevor Chan <trev@trevrosa.dev>
rust: aref: make AlwaysRefCounted::inc_ref an associated function
This commit changes inc_ref from a method to an associated function to
prevent accidental calls. All implementors of AlwaysRefCounted are
updated to reflect this change.
Link: https://github.com/Rust-for-Linux/linux/issues/1177
> diff --git a/rust/kernel/mm.rs b/rust/kernel/mm.rs
> index 4764d7b68f2a7..c955cbd884b8b 100644
> --- a/rust/kernel/mm.rs
> +++ b/rust/kernel/mm.rs
> @@ -57,9 +57,9 @@ unsafe impl Sync for Mm {}
> // SAFETY: By the type invariants, this type is always refcounted.
> unsafe impl AlwaysRefCounted for Mm {
> #[inline]
> - fn inc_ref(&self) {
> + fn inc_ref(obj: &Self) {
> // SAFETY: The pointer is valid since self is a reference.
> - unsafe { bindings::mmgrab(self.as_raw()) };
> + unsafe { bindings::mmgrab(obj.as_raw()) };
[Severity: Low]
This isn't a bug, but should the SAFETY comment be updated to say "since
obj is a reference" instead of "self"?
[ ... ]
> diff --git a/rust/kernel/pwm.rs b/rust/kernel/pwm.rs
> index 6c9d667009ef7..c95b442a972e6 100644
> --- a/rust/kernel/pwm.rs
> +++ b/rust/kernel/pwm.rs
> @@ -631,7 +631,7 @@ pub fn new<'a>(
> // SAFETY: Implements refcounting for `Chip` using the embedded `struct device`.
> unsafe impl<T: PwmOps> AlwaysRefCounted for Chip<T> {
> #[inline]
> - fn inc_ref(&self) {
> + fn inc_ref(obj: &Self) {
> // SAFETY: `self.0.get()` points to a valid `pwm_chip` because `self` exists.
> // The embedded `dev` is valid. `get_device` increments its refcount.
> unsafe { bindings::get_device(&raw mut (*self.0.get()).dev) };
[Severity: Low]
Will this cause a compilation error? The function parameter was renamed
to obj, but the function body still references self in self.0.get().
This isn't a bug on its own, but should the SAFETY comment also be
updated to reference obj instead of self?
[ ... ]
> diff --git a/rust/kernel/usb.rs b/rust/kernel/usb.rs
> index 7aff0c82d0afc..c039059c18913 100644
> --- a/rust/kernel/usb.rs
> +++ b/rust/kernel/usb.rs
> @@ -393,11 +393,11 @@ fn as_ref(&self) -> &Device {
>
> // SAFETY: Instances of `Interface` are always reference-counted.
> unsafe impl AlwaysRefCounted for Interface {
> - fn inc_ref(&self) {
> + fn inc_ref(obj: &Self) {
> // SAFETY: The invariants of `Interface` guarantee that `self.as_raw()`
> // returns a valid `struct usb_interface` pointer, for which we will
> // acquire a new refcount.
> - unsafe { bindings::usb_get_intf(self.as_raw()) };
> + unsafe { bindings::usb_get_intf(obj.as_raw()) };
[Severity: Low]
This isn't a bug, but should the SAFETY comment here also be updated to
reference obj.as_raw() instead of self.as_raw()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260628095132.47753-1-trev@trevrosa.dev?part=1
next prev parent reply other threads:[~2026-06-28 9:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-28 9:51 [PATCH v6] rust: aref: make `AlwaysRefCounted::inc_ref` an associated function Trevor Chan
2026-06-28 9:58 ` sashiko-bot [this message]
2026-06-29 14:37 ` Gary Guo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260628095813.2D6A31F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-pci@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=trev@trevrosa.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox