From 90eed30ad8bcb7681ff5a7de6ebe4df78904d068 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Fri, 24 Sep 2021 18:29:44 +0900 Subject: [PATCH] remove compiler warnings --- vm/src/stdlib/nt.rs | 13 +++++++------ vm/src/stdlib/posix.rs | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/vm/src/stdlib/nt.rs b/vm/src/stdlib/nt.rs index 4d41f62499..9700c95932 100644 --- a/vm/src/stdlib/nt.rs +++ b/vm/src/stdlib/nt.rs @@ -331,6 +331,7 @@ pub(crate) mod module { fn _getdiskusage(path: PyPathLike, vm: &VirtualMachine) -> PyResult<(u64, u64)> { use um::fileapi::GetDiskFreeSpaceExW; use winapi::shared::{ntdef::ULARGE_INTEGER, winerror}; + let wpath = path.to_widecstring(vm)?; let mut _free_to_me = ULARGE_INTEGER::default(); let mut total = ULARGE_INTEGER::default(); @@ -338,7 +339,7 @@ pub(crate) mod module { let ret = unsafe { GetDiskFreeSpaceExW(wpath.as_ptr(), &mut _free_to_me, &mut total, &mut free) }; if ret != 0 { - return unsafe { Ok((*total.QuadPart(), *free.QuadPart())) }; + return Ok(unsafe { (*total.QuadPart(), *free.QuadPart()) }); } let err = io::Error::last_os_error(); if err.raw_os_error() == Some(winerror::ERROR_DIRECTORY as i32) { @@ -349,14 +350,14 @@ pub(crate) mod module { GetDiskFreeSpaceExW(parent.as_ptr(), &mut _free_to_me, &mut total, &mut free) }; - if ret == 0 { - return Err(errno_err(vm)); + return if ret == 0 { + Err(errno_err(vm)) } else { - return unsafe { Ok((*total.QuadPart(), *free.QuadPart())) }; - } + Ok(unsafe { (*total.QuadPart(), *free.QuadPart()) }) + }; } } - return Err(err.into_pyexception(vm)); + Err(err.into_pyexception(vm)) } #[pyfunction] diff --git a/vm/src/stdlib/posix.rs b/vm/src/stdlib/posix.rs index 58d2bff55d..d8271541d9 100644 --- a/vm/src/stdlib/posix.rs +++ b/vm/src/stdlib/posix.rs @@ -31,17 +31,16 @@ pub(crate) fn make_module(vm: &VirtualMachine) -> PyObjectRef { pub mod module { use crate::{ builtins::{int, PyDictRef, PyInt, PyListRef, PyStrRef, PyTupleRef, PyTypeRef}, - crt_fd::Offset, exceptions::IntoPyException, - function::{FuncArgs, OptionalArg}, + function::OptionalArg, slots::SlotConstructor, stdlib::os::{ errno_err, DirFd, FollowSymlinks, PathOrFd, PyPathLike, SupportFunc, TargetIsDirectory, _os, fs_metadata, }, utils::{Either, ToCString}, - IntoPyObject, ItemProtocol, PyObjectRef, PyResult, PyValue, StaticType, - TryFromBorrowedObject, TryFromObject, VirtualMachine, + IntoPyObject, ItemProtocol, PyObjectRef, PyResult, PyValue, StaticType, TryFromObject, + VirtualMachine, }; use bitflags::bitflags; use nix::fcntl; @@ -963,6 +962,8 @@ pub mod module { #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "macos"))] impl PosixSpawnArgs { fn spawn(self, spawnp: bool, vm: &VirtualMachine) -> PyResult { + use crate::TryFromBorrowedObject; + let path = CString::new(self.path.into_bytes()) .map_err(|_| vm.new_value_error("path should not have nul bytes".to_owned()))?; @@ -983,7 +984,7 @@ pub mod module { let id = PosixSpawnFileActionIdentifier::try_from(id).map_err(|_| { vm.new_type_error("Unknown file_actions identifier".to_owned()) })?; - let args = FuncArgs::from(args.to_vec()); + let args: crate::function::FuncArgs = args.to_vec().into(); let ret = match id { PosixSpawnFileActionIdentifier::Open => { let (fd, path, oflag, mode): (_, PyPathLike, _, _) = args.bind(vm)?; @@ -1567,7 +1568,7 @@ pub mod module { #[pyarg(any)] in_fd: i32, #[pyarg(any)] - offset: Offset, + offset: crate::crt_fd::Offset, #[pyarg(any)] count: i64, #[cfg(target_os = "macos")]