Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The SAFETY comment refers to `KBox::into_raw`, but the code calls `Self::into_raw` for a generic `Box<T, A>`. --
commit b26e998f8fbb891dd6bb1b2e1c41a63a8ecd7700 Author: Andreas Hindborg <[email protected]> rust: alloc: add `KBox::into_non_null` This commit adds a method to consume a `Box<T, A>` and return a `NonNull<T>`. It serves as a convenience wrapper around `Self::into_raw` for callers that need a `NonNull` pointer rather than a raw pointer. > diff --git a/rust/kernel/alloc/kbox.rs b/rust/kernel/alloc/kbox.rs > --- a/rust/kernel/alloc/kbox.rs > +++ b/rust/kernel/alloc/kbox.rs [ ... ] > @@ -211,6 +211,15 @@ pub fn leak<'a>(b: Self) -> &'a mut T { > // which points to an initialized instance of `T`. > unsafe { &mut *Box::into_raw(b) } > } > + > + /// Consumes the `Box<T,A>` and returns a `NonNull<T>`. [Severity: Low] This isn't a bug, but there appears to be a missing space after the comma in `Box<T,A>`. Should this be updated to `Box<T, A>` to match standard kernel formatting? > + /// > + /// Like [`Self::into_raw`], but returns a `NonNull`. > + #[inline] > + pub fn into_non_null(b: Self) -> NonNull<T> { > + // SAFETY: `KBox::into_raw` returns a valid pointer. [Severity: Low] This isn't a bug, but the SAFETY comment references `KBox::into_raw`, while the method is implemented for the generic `Box<T, A>` and directly calls `Self::into_raw`. Since `KBox` is an alias specifically for the `Kmalloc` allocator, should the comment refer to `Self::into_raw` or `Box::into_raw` to accurately reflect that this works for any allocator? > + unsafe { NonNull::new_unchecked(Self::into_raw(b)) } > + } > } -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1
