Skip to content

remove compiler warnings #3125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions vm/src/stdlib/nt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,15 @@ 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();
let mut free = ULARGE_INTEGER::default();
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) {
Expand All @@ -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]
Expand Down
13 changes: 7 additions & 6 deletions vm/src/stdlib/posix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<libc::pid_t> {
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()))?;

Expand All @@ -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)?;
Expand Down Expand Up @@ -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")]
Expand Down