From 2016cacb3090dcc4982b2641fd74842c163cf9e4 Mon Sep 17 00:00:00 2001 From: travis1829 Date: Wed, 27 Jan 2021 06:58:38 +0000 Subject: [PATCH] cargo fmt --- kernel-rs/src/pipe.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/kernel-rs/src/pipe.rs b/kernel-rs/src/pipe.rs index d346ff6db..5d2e45ab9 100644 --- a/kernel-rs/src/pipe.rs +++ b/kernel-rs/src/pipe.rs @@ -145,16 +145,28 @@ impl AllocatedPipe { }, ); }; + // Safe since we already wrote a new `Pipe` to `ptr` using `ptr::write()`. + let pipe = unsafe { &*ptr }; let f0 = kernel() .ftable - // Safe since we already wrote a new `Pipe` to `ptr` using `ptr::write()`. - .alloc_file(FileType::Pipe { pipe: unsafe { Self { pipe: &*ptr } } }, true, false) + .alloc_file( + FileType::Pipe { + pipe: Self { pipe }, + }, + true, + false, + ) // It is safe because ptr is an address of page, which obtained by alloc() .map_err(|_| kernel().free(unsafe { Page::from_usize(ptr as _) }))?; let f1 = kernel() .ftable - // Safe since we already wrote a new `Pipe` to `ptr` using `ptr::write()`. - .alloc_file(FileType::Pipe { pipe: unsafe { Self { pipe: &*ptr } } }, false, true) + .alloc_file( + FileType::Pipe { + pipe: Self { pipe }, + }, + false, + true, + ) // It is safe because ptr is an address of page, which obtained by alloc() .map_err(|_| kernel().free(unsafe { Page::from_usize(ptr as _) }))?;