Skip to content

Commit 0fb3a12

Browse files
committed
fmt & clippy
1 parent 499b0b7 commit 0fb3a12

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

src/pty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pub fn posix_openpt(flags: fcntl::OFlag) -> Result<PtyMaster> {
144144
return Err(Errno::last());
145145
}
146146

147-
Ok(PtyMaster(unsafe {OwnedFd::from_raw_fd(fd) }))
147+
Ok(PtyMaster(unsafe { OwnedFd::from_raw_fd(fd) }))
148148
}
149149

150150
/// Get the name of the slave pseudoterminal (see

src/sys/termios.rs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,9 @@ pub fn cfmakesane(termios: &mut Termios) {
11461146
pub fn tcgetattr<Fd: AsFd>(fd: &Fd) -> Result<Termios> {
11471147
let mut termios = mem::MaybeUninit::uninit();
11481148

1149-
let res = unsafe { libc::tcgetattr(fd.as_fd().as_raw_fd(), termios.as_mut_ptr()) };
1149+
let res = unsafe {
1150+
libc::tcgetattr(fd.as_fd().as_raw_fd(), termios.as_mut_ptr())
1151+
};
11501152

11511153
Errno::result(res)?;
11521154

@@ -1159,10 +1161,18 @@ pub fn tcgetattr<Fd: AsFd>(fd: &Fd) -> Result<Termios> {
11591161
/// `tcsetattr()` reconfigures the given port based on a given `Termios` structure. This change
11601162
/// takes affect at a time specified by `actions`. Note that this function may return success if
11611163
/// *any* of the parameters were successfully set, not only if all were set successfully.
1162-
pub fn tcsetattr<Fd: AsFd>(fd: &Fd, actions: SetArg, termios: &Termios) -> Result<()> {
1164+
pub fn tcsetattr<Fd: AsFd>(
1165+
fd: &Fd,
1166+
actions: SetArg,
1167+
termios: &Termios,
1168+
) -> Result<()> {
11631169
let inner_termios = termios.get_libc_termios();
11641170
Errno::result(unsafe {
1165-
libc::tcsetattr(fd.as_fd().as_raw_fd(), actions as c_int, &*inner_termios)
1171+
libc::tcsetattr(
1172+
fd.as_fd().as_raw_fd(),
1173+
actions as c_int,
1174+
&*inner_termios,
1175+
)
11661176
})
11671177
.map(drop)
11681178
}
@@ -1179,7 +1189,10 @@ pub fn tcdrain<Fd: AsFd>(fd: &Fd) -> Result<()> {
11791189
/// `tcflow()` suspends of resumes the transmission or reception of data for the given port
11801190
/// depending on the value of `action`.
11811191
pub fn tcflow<Fd: AsFd>(fd: &Fd, action: FlowArg) -> Result<()> {
1182-
Errno::result(unsafe { libc::tcflow(fd.as_fd().as_raw_fd(), action as c_int) }).map(drop)
1192+
Errno::result(unsafe {
1193+
libc::tcflow(fd.as_fd().as_raw_fd(), action as c_int)
1194+
})
1195+
.map(drop)
11831196
}
11841197

11851198
/// Discard data in the output or input queue (see
@@ -1188,7 +1201,10 @@ pub fn tcflow<Fd: AsFd>(fd: &Fd, action: FlowArg) -> Result<()> {
11881201
/// `tcflush()` will discard data for a terminal port in the input queue, output queue, or both
11891202
/// depending on the value of `action`.
11901203
pub fn tcflush<Fd: AsFd>(fd: &Fd, action: FlushArg) -> Result<()> {
1191-
Errno::result(unsafe { libc::tcflush(fd.as_fd().as_raw_fd(), action as c_int) }).map(drop)
1204+
Errno::result(unsafe {
1205+
libc::tcflush(fd.as_fd().as_raw_fd(), action as c_int)
1206+
})
1207+
.map(drop)
11921208
}
11931209

11941210
/// Send a break for a specific duration (see
@@ -1197,7 +1213,10 @@ pub fn tcflush<Fd: AsFd>(fd: &Fd, action: FlushArg) -> Result<()> {
11971213
/// When using asynchronous data transmission `tcsendbreak()` will transmit a continuous stream
11981214
/// of zero-valued bits for an implementation-defined duration.
11991215
pub fn tcsendbreak<Fd: AsFd>(fd: &Fd, duration: c_int) -> Result<()> {
1200-
Errno::result(unsafe { libc::tcsendbreak(fd.as_fd().as_raw_fd(), duration) }).map(drop)
1216+
Errno::result(unsafe {
1217+
libc::tcsendbreak(fd.as_fd().as_raw_fd(), duration)
1218+
})
1219+
.map(drop)
12011220
}
12021221

12031222
feature! {

test/sys/test_termios.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ fn test_tcgetattr_pty() {
2929
#[test]
3030
fn test_tcgetattr_enotty() {
3131
let file = tempfile().unwrap();
32-
assert_eq!(
33-
termios::tcgetattr(&file).err(),
34-
Some(Errno::ENOTTY)
35-
);
32+
assert_eq!(termios::tcgetattr(&file).err(), Some(Errno::ENOTTY));
3633
}
3734

3835
// Test modifying output flags
@@ -44,8 +41,7 @@ fn test_output_flags() {
4441
// Open one pty to get attributes for the second one
4542
let mut termios = {
4643
let pty = openpty(None, None).expect("openpty failed");
47-
let termios = tcgetattr(&pty.slave).expect("tcgetattr failed");
48-
termios
44+
tcgetattr(&pty.slave).expect("tcgetattr failed")
4945
};
5046

5147
// Make sure postprocessing '\r' isn't specified by default or this test is useless.
@@ -82,8 +78,7 @@ fn test_local_flags() {
8278
// Open one pty to get attributes for the second one
8379
let mut termios = {
8480
let pty = openpty(None, None).unwrap();
85-
let termios = tcgetattr(&pty.slave).unwrap();
86-
termios
81+
tcgetattr(&pty.slave).unwrap()
8782
};
8883

8984
// Make sure echo is specified by default or this test is useless.

test/test_pty.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ fn test_openpty_with_termios() {
213213
// Open one pty to get attributes for the second one
214214
let mut termios = {
215215
let pty = openpty(None, None).unwrap();
216-
let termios = tcgetattr(&pty.slave).unwrap();
217-
termios
216+
tcgetattr(&pty.slave).unwrap()
218217
};
219218
// Make sure newlines are not transformed so the data is preserved when sent.
220219
termios.output_flags.remove(OutputFlags::ONLCR);

0 commit comments

Comments
 (0)