@@ -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