Re: [PATCH v8 11/29] rust: alloc: implement kernel `Box`
From: Danilo Krummrich
Date: Fri Oct 04 2024 - 08:04:25 EST
On Fri, Oct 04, 2024 at 01:00:51AM +0200, Miguel Ojeda wrote:
> On Tue, Oct 1, 2024 at 5:01 PM Danilo Krummrich <dakr@xxxxxxxxxx> wrote:
> >
> > + /// # Examples
> > + ///
> > + /// ```
> > + /// let x = KBox::new(24, GFP_KERNEL)?;
> > + /// let ptr = KBox::into_raw(x);
> > + /// let x = unsafe { KBox::from_raw(ptr) };
>
> This is the only place that, after applying your series on top of the
> lints one (i.e. current `rust-next`), triggered a missing `// SAFETY`
> comment lint :)
>
> If there is no new version, what do you want me to write when I apply it?
diff --git a/rust/kernel/alloc/kbox.rs b/rust/kernel/alloc/kbox.rs
index 5d20f6112cc2..ef1add933f60 100644
--- a/rust/kernel/alloc/kbox.rs
+++ b/rust/kernel/alloc/kbox.rs
@@ -147,6 +147,7 @@ impl<T, A> Box<T, A>
/// ```
/// let x = KBox::new(24, GFP_KERNEL)?;
/// let ptr = KBox::into_raw(x);
+ /// // SAFETY: `ptr` comes from a previous call to `KBox::into_raw`.
/// let x = unsafe { KBox::from_raw(ptr) };
///
/// assert_eq!(*x, 24);
But maybe it's better to just send a new version, to also fix the missing
`#![feature(inline_const)]` for `Vec` and missing import for `size_of` in
`ArrayLayout`.
>
> Thanks!
>
> Cheers,
> Miguel
>