@@ -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 ( ) ;
@@ -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