Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Missing `#[inline]` annotation on the small abstraction function `push_init`. --
commit 3fa22789a74731c2279859cccd39cd9ebf36a551 Author: Eliot Courtney <[email protected]> rust: alloc: add Vec::push_init This commit adds Vec::push_init as an init-infallible version of try_push_init. > diff --git a/rust/kernel/alloc/kvec.rs b/rust/kernel/alloc/kvec.rs > index fe86530624c1b..bb4da220293bc 100644 > --- a/rust/kernel/alloc/kvec.rs > +++ b/rust/kernel/alloc/kvec.rs [ ... ] > @@ -369,7 +369,24 @@ pub fn push(&mut self, v: T, flags: Flags) -> Result<(), > AllocError> { > > /// Appends an element to the back of the [`Vec`] instance by > initializing it in place. > /// > - /// Unlike [`Vec::push`], the initializer may be fallible. If the > allocation fails, the > + /// # Examples > + /// > + /// ``` > + /// use pin_init::init_zeroed; > + /// > + /// let mut v = KVec::<[u8; 200]>::new(); > + /// v.push_init(init_zeroed(), GFP_KERNEL)?; > + /// assert_eq!(v[0], [0; 200]); > + /// # Ok::<(), Error>(()) > + /// ``` > + pub fn push_init(&mut self, init: impl Init<T>, flags: Flags) -> > Result<(), AllocError> { [Severity: Low] Should this small wrapper function be annotated with #[inline]? The Rust subsystem guidelines state that small functions in abstraction crates like kernel should be annotated with #[inline]. Since push_init is a small abstraction forwarding to try_push_init, omitting the inline annotation may inhibit cross-crate inlining by the compiler optimizer when it is invoked from an external crate (like a driver), leading to unnecessary function call overhead. > + self.try_push_init(init, flags) > + .map_err(|PushInitError::AllocError(_)| AllocError) > + } -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=2
