Skip to content

Commit

Permalink
TEMP: rust: Adjustment of allocation API changes
Browse files Browse the repository at this point in the history
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
  • Loading branch information
fbq committed Mar 29, 2024
1 parent 1decb83 commit 6007000
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions rust/kernel/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
//! [`include/linux/file.h`](srctree/include/linux/file.h)

use crate::{
alloc::AllocError,
bindings,
cred::Credential,
error::{code::*, Error, Result},
prelude::*,
types::{ARef, AlwaysRefCounted, NotThreadSafe, Opaque},
};
use alloc::boxed::Box;
use core::{alloc::AllocError, mem, ptr};
use core::{mem, ptr};

/// Flags associated with a [`File`].
pub mod flags {
Expand Down Expand Up @@ -348,10 +350,13 @@ impl DeferredFdCloser {
pub fn new() -> Result<Self, AllocError> {
Ok(Self {
// INVARIANT: The `file` pointer is null, so the type invariant does not apply.
inner: Box::try_new(DeferredFdCloserInner {
twork: mem::MaybeUninit::uninit(),
file: core::ptr::null_mut(),
})?,
inner: <Box<_> as BoxExt<_>>::new(
DeferredFdCloserInner {
twork: mem::MaybeUninit::uninit(),
file: core::ptr::null_mut(),
},
GFP_KERNEL,
)?,
})
}

Expand Down
4 changes: 2 additions & 2 deletions rust/kernel/sync/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ impl<T: ?Sized> Arc<T> {
/// ```
/// use kernel::sync::{Arc, UniqueArc};
///
/// let arc = Arc::try_new(42)?;
/// let arc = Arc::new(42, GFP_KERNEL)?;
/// let unique_arc = arc.into_unique_or_drop();
///
/// // The above conversion should succeed since refcount of `arc` is 1.
Expand All @@ -316,7 +316,7 @@ impl<T: ?Sized> Arc<T> {
/// ```
/// use kernel::sync::{Arc, UniqueArc};
///
/// let arc = Arc::try_new(42)?;
/// let arc = Arc::new(42, GFP_KERNEL)?;
/// let another = arc.clone();
///
/// let unique_arc = arc.into_unique_or_drop();
Expand Down

0 comments on commit 6007000

Please sign in to comment.