diff --git a/vm/src/stdlib/multiprocessing.rs b/vm/src/stdlib/multiprocessing.rs index 99cb5a1e89..b1848e5b37 100644 --- a/vm/src/stdlib/multiprocessing.rs +++ b/vm/src/stdlib/multiprocessing.rs @@ -18,7 +18,7 @@ mod _multiprocessing { #[pyfunction] fn recv(socket: usize, size: usize, vm: &VirtualMachine) -> PyResult { - 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 { diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index eaf702e719..bcc50da1b4 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -3716,7 +3716,7 @@ mod nt { } } } - return Err(err.into_pyexception(vm)); + Err(err.into_pyexception(vm)) } #[pyfunction] diff --git a/vm/src/stdlib/winapi.rs b/vm/src/stdlib/winapi.rs index 397d353eac..5ca3e20712 100644 --- a/vm/src/stdlib/winapi.rs +++ b/vm/src/stdlib/winapi.rs @@ -258,9 +258,9 @@ fn getattributelist(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult>>::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() }) diff --git a/vm/src/stdlib/winreg.rs b/vm/src/stdlib/winreg.rs index 2c751be574..d1793acbc1 100644 --- a/vm/src/stdlib/winreg.rs +++ b/vm/src/stdlib/winreg.rs @@ -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 { diff --git a/vm/src/sysmodule.rs b/vm/src/sysmodule.rs index 1dcac442e2..7a4461d463 100644 --- a/vm/src/sysmodule.rs +++ b/vm/src/sysmodule.rs @@ -294,8 +294,10 @@ fn sys_getwindowsversion(vm: &VirtualMachine) -> PyResult() as u32; + let mut version = OSVERSIONINFOEXW { + dwOSVersionInfoSize: std::mem::size_of::() 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.