Skip to content

Commit d37da5c

Browse files
committed
Cleanup code
1 parent aac5217 commit d37da5c

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

native/src/core/bootstages.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use nix::fcntl::OFlag;
1616
use std::io::BufReader;
1717
use std::os::unix::net::UnixStream;
1818
use std::process::{Command, Stdio};
19-
use std::sync::atomic::{AtomicBool, Ordering};
19+
use std::sync::atomic::Ordering;
2020

2121
bitflags! {
2222
#[derive(Default)]

native/src/core/su/pts.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use nix::{
1010
};
1111
use std::fs::File;
1212
use std::io::{Read, Write};
13-
use std::mem::{ManuallyDrop, MaybeUninit};
14-
use std::os::fd::{AsFd, AsRawFd, FromRawFd, OwnedFd, RawFd};
13+
use std::mem::MaybeUninit;
14+
use std::os::fd::{AsFd, AsRawFd, FromRawFd, RawFd};
1515
use std::sync::atomic::{AtomicBool, Ordering};
1616

1717
static SHOULD_USE_SPLICE: AtomicBool = AtomicBool::new(true);
@@ -50,7 +50,7 @@ fn pump_via_copy(mut fd_in: &File, mut fd_out: &File) -> LoggedResult<()> {
5050
Ok(())
5151
}
5252

53-
fn pump_via_splice(fd_in: &File, fd_out: &File, pipe: &(OwnedFd, OwnedFd)) -> LoggedResult<()> {
53+
fn pump_via_splice(fd_in: &File, fd_out: &File, pipe: &(File, File)) -> LoggedResult<()> {
5454
if !SHOULD_USE_SPLICE.load(Ordering::Relaxed) {
5555
return pump_via_copy(fd_in, fd_out);
5656
}
@@ -64,10 +64,10 @@ fn pump_via_splice(fd_in: &File, fd_out: &File, pipe: &(OwnedFd, OwnedFd)) -> Lo
6464
if len == 0 {
6565
return Ok(());
6666
}
67-
if let Err(_) = splice(&pipe.0, fd_out, len) {
67+
if splice(&pipe.0, fd_out, len).is_err() {
6868
// If splice failed, stop using splice and fallback to userspace copy
6969
SHOULD_USE_SPLICE.store(false, Ordering::Relaxed);
70-
return pump_via_copy(&ManuallyDrop::new(unsafe { File::from_raw_fd(pipe.0.as_raw_fd()) }), fd_out);
70+
return pump_via_copy(&pipe.0, fd_out);
7171
}
7272
Ok(())
7373
}
@@ -132,6 +132,7 @@ fn pump_tty_impl(ptmx: File, pump_stdin: bool) -> LoggedResult<()> {
132132

133133
// Open a pipe to bypass userspace copy with splice
134134
let pipe_fd = pipe2(OFlag::O_CLOEXEC).into_os_result("pipe2", None, None)?;
135+
let pipe_fd = (File::from(pipe_fd.0), File::from(pipe_fd.1));
135136

136137
'poll: loop {
137138
// Wait for event

0 commit comments

Comments
 (0)