Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
travis1829 committed Jan 27, 2021
1 parent b765f2f commit 2016cac
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions kernel-rs/src/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _) }))?;

Expand Down

0 comments on commit 2016cac

Please sign in to comment.