Merge pull request #3113 from Snowapril/solve-clippy-warnings

Solve clippy warnings in window
This commit is contained in:
Jeong YunWon
2021-09-23 00:23:42 +09:00
committed by GitHub
5 changed files with 10 additions and 8 deletions

View File

@@ -18,7 +18,7 @@ mod _multiprocessing {
#[pyfunction]
fn recv(socket: usize, size: usize, vm: &VirtualMachine) -> PyResult<libc::c_int> {
let mut buf = vec![0 as libc::c_char; size];
let mut buf = vec![0; size];
let nread =
unsafe { winsock2::recv(socket as SOCKET, buf.as_mut_ptr() as *mut _, size as i32, 0) };
if nread < 0 {

View File

@@ -3716,7 +3716,7 @@ mod nt {
}
}
}
return Err(err.into_pyexception(vm));
Err(err.into_pyexception(vm))
}
#[pyfunction]

View File

@@ -258,9 +258,9 @@ fn getattributelist(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult<Option<At
.get_item_option("handle_list", vm)?
.and_then(|obj| {
<Option<PySequence<usize>>>::try_from_object(vm, obj)
.and_then(|s| match s {
Some(s) if !s.as_slice().is_empty() => Ok(Some(s.into_vec())),
_ => Ok(None),
.map(|s| match s {
Some(s) if !s.as_slice().is_empty() => Some(s.into_vec()),
_ => None,
})
.transpose()
})

View File

@@ -276,7 +276,7 @@ fn reg_to_py(value: RegValue, vm: &VirtualMachine) -> PyResult {
.collect();
Ok(vm.ctx.new_list(strings))
}
RegType::REG_BINARY | _ => {
_ => {
if value.bytes.is_empty() {
Ok(vm.ctx.none())
} else {

View File

@@ -294,8 +294,10 @@ fn sys_getwindowsversion(vm: &VirtualMachine) -> PyResult<crate::builtins::tuple
winnt::{LPOSVERSIONINFOEXW, LPOSVERSIONINFOW, OSVERSIONINFOEXW},
};
let mut version = OSVERSIONINFOEXW::default();
version.dwOSVersionInfoSize = std::mem::size_of::<OSVERSIONINFOEXW>() as u32;
let mut version = OSVERSIONINFOEXW {
dwOSVersionInfoSize: std::mem::size_of::<OSVERSIONINFOEXW>() as u32,
..OSVERSIONINFOEXW::default()
};
let result = unsafe {
let osvi = &mut version as LPOSVERSIONINFOEXW as LPOSVERSIONINFOW;
// SAFETY: GetVersionExW accepts a pointer of OSVERSIONINFOW, but winapi crate's type currently doesn't allow to do so.