Skip to content

Commit dd5d84b

Browse files
Upgrade nix to v0.30
1 parent 6e22fa6 commit dd5d84b

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
@@ -105,7 +105,6 @@ impl TTYPort {
105105
OFlag::O_RDWR | OFlag::O_NOCTTY | OFlag::O_NONBLOCK | OFlag::O_CLOEXEC,
106106
nix::sys::stat::Mode::empty(),
107107
)?;
108-
let fd = unsafe { OwnedFd::from_raw_fd(fd) };
109108

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

151150
// clear O_NONBLOCK flag
152-
fcntl(fd.as_raw_fd(), F_SETFL(nix::fcntl::OFlag::empty()))?;
151+
fcntl(fd.as_fd(), F_SETFL(nix::fcntl::OFlag::empty()))?;
153152

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

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

299297
fcntl(
300-
fd.as_raw_fd(),
298+
fd.as_fd(),
301299
nix::fcntl::FcntlArg::F_SETFL(nix::fcntl::OFlag::empty()),
302300
)?;
303301

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

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

0 commit comments

Comments
 (0)