Skip to content

Commit 0202a14

Browse files
committed
rustfmt the NetBSD implementation
1 parent 9ae1f96 commit 0202a14

File tree

3 files changed

+19
-22
lines changed

3 files changed

+19
-22
lines changed

src/netbsd/device.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
extern crate libc;
66

7-
use std::mem;
7+
use std::io;
88
use std::io::Read;
99
use std::io::Write;
10-
use std::io;
10+
use std::mem;
1111

1212
use consts::CID_BROADCAST;
1313
use consts::HID_RPT_SIZE;
@@ -24,7 +24,10 @@ pub struct Device {
2424

2525
impl Device {
2626
pub fn new(fd: Fd) -> io::Result<Self> {
27-
Ok(Self { fd, cid: CID_BROADCAST })
27+
Ok(Self {
28+
fd,
29+
cid: CID_BROADCAST,
30+
})
2831
}
2932

3033
pub fn is_u2f(&mut self) -> bool {
@@ -52,14 +55,14 @@ impl Device {
5255
for i in 0..10 {
5356
let mut buf = vec![0u8; 1 + HID_RPT_SIZE];
5457

55-
buf[0] = 0; // report number
56-
buf[1] = 0xff; // CID_BROADCAST
58+
buf[0] = 0; // report number
59+
buf[1] = 0xff; // CID_BROADCAST
5760
buf[2] = 0xff;
5861
buf[3] = 0xff;
5962
buf[4] = 0xff;
60-
buf[5] = 0x81; // ping
63+
buf[5] = 0x81; // ping
6164
buf[6] = 0;
62-
buf[7] = 1; // one byte
65+
buf[7] = 1; // one byte
6366

6467
self.write(&buf[..])?;
6568

@@ -108,9 +111,7 @@ impl Write for Device {
108111
// Always skip the first byte (report number)
109112
let data = &buf[1..];
110113
let data_ptr = data.as_ptr() as *const libc::c_void;
111-
let nwrit = unsafe {
112-
libc::write(self.fd.fileno, data_ptr, data.len())
113-
};
114+
let nwrit = unsafe { libc::write(self.fd.fileno, data_ptr, data.len()) };
114115
if nwrit == -1 {
115116
return Err(io::Error::last_os_error());
116117
}

src/netbsd/monitor.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,11 @@ where
4444
match Fd::open(&uhidpath, libc::O_RDWR | libc::O_CLOEXEC) {
4545
Ok(uhid) => {
4646
self.add_device(uhid, OsString::from(&uhidpath));
47-
},
48-
Err(ref err) => {
49-
match err.raw_os_error() {
50-
Some(libc::EBUSY) => continue,
51-
Some(libc::ENOENT) => break,
52-
_ => self.remove_device(OsString::from(&uhidpath)),
53-
}
47+
}
48+
Err(ref err) => match err.raw_os_error() {
49+
Some(libc::EBUSY) => continue,
50+
Some(libc::ENOENT) => break,
51+
_ => self.remove_device(OsString::from(&uhidpath)),
5452
},
5553
}
5654
}

src/netbsd/uhid.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use std::mem;
99
use std::os::raw::c_int;
1010
use std::os::raw::c_uchar;
1111

12-
use hidproto::ReportDescriptor;
1312
use hidproto::has_fido_usage;
13+
use hidproto::ReportDescriptor;
1414
use platform::fd::Fd;
1515
use util::io_err;
1616

@@ -27,11 +27,9 @@ const IOC_IN: u32 = 0x80000000;
2727

2828
macro_rules! ioctl {
2929
($dir:expr, $name:ident, $group:expr, $nr:expr, $ty:ty) => {
30-
unsafe fn $name(fd: libc::c_int, val: *mut $ty)
31-
-> io::Result<libc::c_int> {
30+
unsafe fn $name(fd: libc::c_int, val: *mut $ty) -> io::Result<libc::c_int> {
3231
let ioc = ($dir as u32)
33-
| ((mem::size_of::<$ty>() as u32 & IOCPARM_MASK)
34-
<< IOCPARM_SHIFT)
32+
| ((mem::size_of::<$ty>() as u32 & IOCPARM_MASK) << IOCPARM_SHIFT)
3533
| (($group as u32) << IOCGROUP_SHIFT)
3634
| ($nr as u32);
3735
let rv = libc::ioctl(fd, ioc as libc::c_ulong, val);

0 commit comments

Comments
 (0)