Skip to content

Commit 0223da9

Browse files
committed
Fix "mismatched types" errors from new nix version
1 parent 632888b commit 0223da9

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/uu/cat/src/splice.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
use super::{CatResult, FdReadable, InputHandle};
66

77
use nix::unistd;
8-
use std::os::unix::io::{AsRawFd, RawFd};
8+
use std::{
9+
fs::File,
10+
os::{
11+
fd::FromRawFd,
12+
unix::io::{AsRawFd, RawFd},
13+
},
14+
};
915

1016
use uucore::pipes::{pipe, splice, splice_exact};
1117

@@ -60,9 +66,11 @@ fn copy_exact(read_fd: RawFd, write_fd: RawFd, num_bytes: usize) -> nix::Result<
6066
assert_ne!(read, 0, "unexpected end of pipe");
6167
let mut written = 0;
6268
while written < read {
63-
match unistd::write(write_fd, &buf[written..read])? {
64-
0 => panic!(),
65-
n => written += n,
69+
unsafe {
70+
match unistd::write(File::from_raw_fd(write_fd), &buf[written..read])? {
71+
0 => panic!(),
72+
n => written += n,
73+
}
6674
}
6775
}
6876
left -= read;

src/uucore/src/lib/features/pipes.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use std::fs::File;
88
use std::io::IoSlice;
99
#[cfg(any(target_os = "linux", target_os = "android"))]
1010
use std::os::unix::io::AsRawFd;
11-
use std::os::unix::io::FromRawFd;
1211

1312
#[cfg(any(target_os = "linux", target_os = "android"))]
1413
use nix::fcntl::SpliceFFlags;
@@ -21,8 +20,7 @@ pub use nix::{Error, Result};
2120
/// from the first.
2221
pub fn pipe() -> Result<(File, File)> {
2322
let (read, write) = nix::unistd::pipe()?;
24-
// SAFETY: The file descriptors do not have other owners.
25-
unsafe { Ok((File::from_raw_fd(read), File::from_raw_fd(write))) }
23+
Ok((File::from(read), File::from(write)))
2624
}
2725

2826
/// Less noisy wrapper around [`nix::fcntl::splice`].

0 commit comments

Comments
 (0)