@@ -106,7 +106,6 @@ impl TTYPort {
106
106
OFlag :: O_RDWR | OFlag :: O_NOCTTY | OFlag :: O_NONBLOCK | OFlag :: O_CLOEXEC ,
107
107
nix:: sys:: stat:: Mode :: empty ( ) ,
108
108
) ?;
109
- let fd = unsafe { OwnedFd :: from_raw_fd ( fd) } ;
110
109
111
110
// Try to claim exclusive access to the port. This is performed even
112
111
// if the port will later be set as non-exclusive, in order to respect
@@ -150,7 +149,7 @@ impl TTYPort {
150
149
}
151
150
152
151
// 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 ( ) ) ) ?;
154
153
155
154
// Configure the low-level port settings
156
155
let mut termios = termios:: get_termios ( fd. as_raw_fd ( ) ) ?;
@@ -284,7 +283,6 @@ impl TTYPort {
284
283
OFlag :: O_RDWR | OFlag :: O_NOCTTY | OFlag :: O_NONBLOCK ,
285
284
nix:: sys:: stat:: Mode :: empty ( ) ,
286
285
) ?;
287
- let fd = unsafe { OwnedFd :: from_raw_fd ( fd) } ;
288
286
289
287
// Set the port to a raw state. Using these ports will not work without this.
290
288
let mut termios = MaybeUninit :: uninit ( ) ;
@@ -298,7 +296,7 @@ impl TTYPort {
298
296
unsafe { crate :: posix:: tty:: libc:: tcsetattr ( fd. as_raw_fd ( ) , libc:: TCSANOW , & termios) } ;
299
297
300
298
fcntl (
301
- fd. as_raw_fd ( ) ,
299
+ fd. as_fd ( ) ,
302
300
nix:: fcntl:: FcntlArg :: F_SETFL ( nix:: fcntl:: OFlag :: empty ( ) ) ,
303
301
) ?;
304
302
@@ -351,7 +349,7 @@ impl TTYPort {
351
349
/// This function returns an error if the serial port couldn't be cloned.
352
350
pub fn try_clone_native ( & self ) -> Result < TTYPort > {
353
351
let fd_cloned: i32 = fcntl (
354
- self . fd . as_raw_fd ( ) ,
352
+ self . fd . as_fd ( ) ,
355
353
nix:: fcntl:: F_DUPFD_CLOEXEC ( self . fd . as_raw_fd ( ) ) ,
356
354
) ?;
357
355
Ok ( TTYPort {
@@ -412,7 +410,7 @@ impl io::Read for TTYPort {
412
410
return Err ( io:: Error :: from ( Error :: from ( e) ) ) ;
413
411
}
414
412
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) ) )
416
414
}
417
415
}
418
416
0 commit comments