Skip to content

Commit 90ab58e

Browse files
Upgrade nix to v0.30
1 parent 0ae2ec6 commit 90ab58e

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ categories = ["hardware-support"]
1616

1717
[target."cfg(unix)".dependencies]
1818
bitflags = "2.4.0"
19-
nix = { version = "0.29", default-features = false, features = ["fs", "ioctl", "poll", "signal", "term"] }
19+
nix = { version = "0.30", default-features = false, features = ["fs", "ioctl", "poll", "signal", "term"] }
2020

2121
[target.'cfg(all(target_os = "linux", not(target_env = "musl")))'.dependencies]
2222
libudev = { version = "0.3.0", optional = true }

src/posix/tty.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ impl TTYPort {
106106
OFlag::O_RDWR | OFlag::O_NOCTTY | OFlag::O_NONBLOCK | OFlag::O_CLOEXEC,
107107
nix::sys::stat::Mode::empty(),
108108
)?;
109-
let fd = unsafe { OwnedFd::from_raw_fd(fd) };
110109

111110
// Try to claim exclusive access to the port. This is performed even
112111
// if the port will later be set as non-exclusive, in order to respect
@@ -150,7 +149,7 @@ impl TTYPort {
150149
}
151150

152151
// clear O_NONBLOCK flag
153-
fcntl(fd.as_raw_fd(), F_SETFL(nix::fcntl::OFlag::empty()))?;
152+
fcntl(fd.as_fd(), F_SETFL(nix::fcntl::OFlag::empty()))?;
154153

155154
// Configure the low-level port settings
156155
let mut termios = termios::get_termios(fd.as_raw_fd())?;
@@ -284,7 +283,6 @@ impl TTYPort {
284283
OFlag::O_RDWR | OFlag::O_NOCTTY | OFlag::O_NONBLOCK,
285284
nix::sys::stat::Mode::empty(),
286285
)?;
287-
let fd = unsafe { OwnedFd::from_raw_fd(fd) };
288286

289287
// Set the port to a raw state. Using these ports will not work without this.
290288
let mut termios = MaybeUninit::uninit();
@@ -298,7 +296,7 @@ impl TTYPort {
298296
unsafe { crate::posix::tty::libc::tcsetattr(fd.as_raw_fd(), libc::TCSANOW, &termios) };
299297

300298
fcntl(
301-
fd.as_raw_fd(),
299+
fd.as_fd(),
302300
nix::fcntl::FcntlArg::F_SETFL(nix::fcntl::OFlag::empty()),
303301
)?;
304302

@@ -351,7 +349,7 @@ impl TTYPort {
351349
/// This function returns an error if the serial port couldn't be cloned.
352350
pub fn try_clone_native(&self) -> Result<TTYPort> {
353351
let fd_cloned: i32 = fcntl(
354-
self.fd.as_raw_fd(),
352+
self.fd.as_fd(),
355353
nix::fcntl::F_DUPFD_CLOEXEC(self.fd.as_raw_fd()),
356354
)?;
357355
Ok(TTYPort {
@@ -412,7 +410,7 @@ impl io::Read for TTYPort {
412410
return Err(io::Error::from(Error::from(e)));
413411
}
414412

415-
nix::unistd::read(self.fd.as_raw_fd(), buf).map_err(|e| io::Error::from(Error::from(e)))
413+
nix::unistd::read(self.fd.as_fd(), buf).map_err(|e| io::Error::from(Error::from(e)))
416414
}
417415
}
418416

0 commit comments

Comments
 (0)