Skip to content

Commit 6007000

Browse files
committed
TEMP: rust: Adjustment of allocation API changes
Signed-off-by: Boqun Feng <[email protected]>
1 parent 1decb83 commit 6007000

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

rust/kernel/file.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
//! [`include/linux/file.h`](srctree/include/linux/file.h)
77
88
use crate::{
9+
alloc::AllocError,
910
bindings,
1011
cred::Credential,
1112
error::{code::*, Error, Result},
13+
prelude::*,
1214
types::{ARef, AlwaysRefCounted, NotThreadSafe, Opaque},
1315
};
1416
use alloc::boxed::Box;
15-
use core::{alloc::AllocError, mem, ptr};
17+
use core::{mem, ptr};
1618

1719
/// Flags associated with a [`File`].
1820
pub mod flags {
@@ -348,10 +350,13 @@ impl DeferredFdCloser {
348350
pub fn new() -> Result<Self, AllocError> {
349351
Ok(Self {
350352
// INVARIANT: The `file` pointer is null, so the type invariant does not apply.
351-
inner: Box::try_new(DeferredFdCloserInner {
352-
twork: mem::MaybeUninit::uninit(),
353-
file: core::ptr::null_mut(),
354-
})?,
353+
inner: <Box<_> as BoxExt<_>>::new(
354+
DeferredFdCloserInner {
355+
twork: mem::MaybeUninit::uninit(),
356+
file: core::ptr::null_mut(),
357+
},
358+
GFP_KERNEL,
359+
)?,
355360
})
356361
}
357362

rust/kernel/sync/arc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl<T: ?Sized> Arc<T> {
302302
/// ```
303303
/// use kernel::sync::{Arc, UniqueArc};
304304
///
305-
/// let arc = Arc::try_new(42)?;
305+
/// let arc = Arc::new(42, GFP_KERNEL)?;
306306
/// let unique_arc = arc.into_unique_or_drop();
307307
///
308308
/// // The above conversion should succeed since refcount of `arc` is 1.
@@ -316,7 +316,7 @@ impl<T: ?Sized> Arc<T> {
316316
/// ```
317317
/// use kernel::sync::{Arc, UniqueArc};
318318
///
319-
/// let arc = Arc::try_new(42)?;
319+
/// let arc = Arc::new(42, GFP_KERNEL)?;
320320
/// let another = arc.clone();
321321
///
322322
/// let unique_arc = arc.into_unique_or_drop();

0 commit comments

Comments
 (0)