Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Low] The newly added invariant comment incorrectly states the faux device is 'bound to a device' instead of 'bound to a driver'. - [Low] Missing `// INVARIANT:` comment justification for the newly added type invariant in the constructor `Registration::new()`. --
commit 4f6cdb361b5df7689eb3f97b5d9628c28576af9e Author: Lyude Paul <[email protected]> rust: faux: Allow retrieving a bound Device This commit allows retrieving a Bound device context from a faux::Registration by implementing AsRef<device::Device<device::Bound>>. It also adds a new type invariant stating that the Registration object proves the device is bound. > diff --git a/rust/kernel/faux.rs b/rust/kernel/faux.rs > index 43b4974f48cd2..20ab638885354 100644 > --- a/rust/kernel/faux.rs > +++ b/rust/kernel/faux.rs > @@ -25,7 +25,8 @@ > /// > /// # Invariants > /// > -/// `self.0` always holds a valid pointer to an initialized and registered > [`struct faux_device`]. > +/// - `self.0` always holds a valid pointer to an initialized and registered > [`struct faux_device`]. > +/// - This object is proof that the object described by this `Registration` > is bound to a device. [Severity: Low] This isn't a bug, but should this say "bound to a driver" instead of "bound to a device"? A faux device is bound to a driver, not another device. [Severity: Low] Since a new invariant was added here, does Registration::new() need an updated // INVARIANT: comment to justify it? According to the subsystem guidelines, when a struct with an # Invariants section is constructed, there must be a corresponding // INVARIANT: comment. The current constructor only justifies the first invariant: rust/kernel/faux.rs:Registration::new() { ... // The above function will return either a valid device, or NULL on failure // INVARIANT: The device will remain registered until faux_device_destroy() is called, which // happens in our Drop implementation. Ok(Self(NonNull::new(dev).ok_or(ENODEV)?)) } -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=3
