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