Skip to content

Commit e33c10f

Browse files
committed
Fix clippy
1 parent 9b6c078 commit e33c10f

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

src/windows/dcb.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ pub(crate) fn get_dcb(handle: HANDLE) -> Result<DCB> {
1111
dcb.DCBlength = std::mem::size_of::<DCB>() as u32;
1212

1313
if unsafe { GetCommState(handle, &mut dcb) } != 0 {
14-
return Ok(dcb);
14+
Ok(dcb)
1515
} else {
16-
return Err(super::error::last_os_error());
16+
Err(super::error::last_os_error())
1717
}
1818
}
1919

@@ -57,9 +57,9 @@ pub(crate) fn init(dcb: &mut DCB) {
5757

5858
pub(crate) fn set_dcb(handle: HANDLE, mut dcb: DCB) -> Result<()> {
5959
if unsafe { SetCommState(handle, &mut dcb as *mut _) != 0 } {
60-
return Ok(());
60+
Ok(())
6161
} else {
62-
return Err(super::error::last_os_error());
62+
Err(super::error::last_os_error())
6363
}
6464
}
6565

src/windows/enumerate.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ fn get_ports_guids() -> Result<Vec<GUID>> {
2929

3030
// Size vector to hold 1 result (which is the most common result).
3131
let mut num_guids: DWORD = 0;
32-
let mut guids: Vec<GUID> = Vec::new();
33-
guids.push(GUID_NULL); // Placeholder for first result
32+
let mut guids = vec![GUID_NULL]; // Placeholder for first result
3433

3534
// Find out how many GUIDs are associated with "Ports". Initially we assume
3635
// that there is only 1. num_guids will tell us how many there actually are.
@@ -272,10 +271,8 @@ impl PortDevice {
272271
ptr::null_mut(),
273272
)
274273
};
275-
if res == FALSE {
276-
if unsafe { GetLastError() } != ERROR_INSUFFICIENT_BUFFER {
277-
return None;
278-
}
274+
if res == FALSE && unsafe { GetLastError() } != ERROR_INSUFFICIENT_BUFFER {
275+
return None;
279276
}
280277
let end_of_buffer = result_buf.len() - 1;
281278
result_buf[end_of_buffer] = 0;
@@ -307,7 +304,7 @@ pub fn available_ports() -> Result<Vec<SerialPortInfo>> {
307304
}
308305

309306
ports.push(SerialPortInfo {
310-
port_name: port_name,
307+
port_name,
311308
port_type: port_device.port_type(),
312309
});
313310
}

src/windows/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use winapi::um::errhandlingapi::GetLastError;
77
use winapi::um::winbase::{
88
FormatMessageW, FORMAT_MESSAGE_FROM_SYSTEM, FORMAT_MESSAGE_IGNORE_INSERTS,
99
};
10-
use winapi::um::winnt::{LANG_SYSTEM_DEFAULT, MAKELANGID, SUBLANG_SYS_DEFAULT, WCHAR};
10+
use winapi::um::winnt::{LANG_SYSTEM_DEFAULT, MAKELANGID, SUBLANG_SYS_DEFAULT};
1111

1212
use crate::{Error, ErrorKind};
1313

@@ -35,7 +35,7 @@ fn error_string(errnum: u32) -> String {
3535
// MAKELANGID(LANG_SYSTEM_DEFAULT, SUBLANG_SYS_DEFAULT)
3636
let langId = MAKELANGID(LANG_SYSTEM_DEFAULT, SUBLANG_SYS_DEFAULT) as DWORD;
3737

38-
let mut buf = [0 as WCHAR; 2048];
38+
let mut buf = [0u16; 2048];
3939

4040
unsafe {
4141
let res = FormatMessageW(

0 commit comments

Comments
 (0)