Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
CraftSpider committed Jan 30, 2025
1 parent e740a04 commit 2e11722
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
12 changes: 5 additions & 7 deletions src/shims/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,7 @@ impl FileDescription for FileHandle {
}

fn read<'tcx>(
&self,
_self_ref: &FileDescriptionRef,
self: FileDescriptionRef<Self>,
communicate_allowed: bool,
ptr: Pointer,
len: usize,
Expand All @@ -319,8 +318,7 @@ impl FileDescription for FileHandle {
}

fn write<'tcx>(
&self,
_self_ref: &FileDescriptionRef,
self: FileDescriptionRef<Self>,
communicate_allowed: bool,
ptr: Pointer,
len: usize,
Expand All @@ -346,7 +344,7 @@ impl FileDescription for FileHandle {
}

fn close<'tcx>(
self: Box<Self>,
self,
communicate_allowed: bool,
_ecx: &mut MiriInterpCx<'tcx>,
) -> InterpResult<'tcx, io::Result<()>> {
Expand All @@ -357,7 +355,7 @@ impl FileDescription for FileHandle {
// to handle possible errors correctly.
let result = self.file.sync_all();
// Now we actually close the file and return the result.
drop(*self);
drop(self);
interp_ok(result)
} else {
// We drop the file, this closes it but ignores any errors
Expand All @@ -366,7 +364,7 @@ impl FileDescription for FileHandle {
// `/dev/urandom` which are read-only. Check
// https://github.com/rust-lang/miri/issues/999#issuecomment-568920439
// for a deeper discussion.
drop(*self);
drop(self);
interp_ok(Ok(()))
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/shims/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_data_structures::fx::FxHashMap;

use self::shims::time::system_time_to_duration;
use crate::helpers::check_min_vararg_count;
use crate::shims::files::{EvalContextExt as _, FileHandle, FileDescription, FileDescriptionRef};
use crate::shims::files::{EvalContextExt as _, FileHandle};
use crate::shims::os_str::bytes_to_os_str;
use crate::shims::unix::fd::{FlockOp, UnixFileDescription};
use crate::*;
Expand Down
5 changes: 2 additions & 3 deletions src/shims/windows/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
creation_disposition,
flags_and_attributes,
template_file,
] = this.check_shim(abi, ExternAbi::System { unwind: false }, link_name, args)?;
] = this.check_shim(abi, sys_conv, link_name, args)?;
let handle = this.CreateFileW(
file_name,
desired_access,
Expand All @@ -263,8 +263,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
this.write_scalar(handle.to_scalar(this), dest)?;
}
"GetFileInformationByHandle" => {
let [handle, info] =
this.check_shim(abi, ExternAbi::System { unwind: false }, link_name, args)?;
let [handle, info] = this.check_shim(abi, sys_conv, link_name, args)?;
let res = this.GetFileInformationByHandle(handle, info)?;
this.write_scalar(res, dest)?;
}
Expand Down
14 changes: 7 additions & 7 deletions src/shims/windows/fs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::fs::{Metadata, OpenOptions};
use std::io;
use std::io::ErrorKind;
use std::path::PathBuf;
use std::time::SystemTime;

Expand All @@ -25,7 +24,7 @@ impl FileDescription for DirHandle {
}

fn close<'tcx>(
self: Box<Self>,
self,
_communicate_allowed: bool,
_ecx: &mut MiriInterpCx<'tcx>,
) -> InterpResult<'tcx, io::Result<()>> {
Expand All @@ -51,7 +50,7 @@ impl FileDescription for MetadataHandle {
}

fn close<'tcx>(
self: Box<Self>,
self,
_communicate_allowed: bool,
_ecx: &mut MiriInterpCx<'tcx>,
) -> InterpResult<'tcx, io::Result<()>> {
Expand Down Expand Up @@ -115,7 +114,7 @@ impl FileAttributes {
fn new<'tcx>(
mut value: u32,
ecx: &mut MiriInterpCx<'tcx>,
) -> InterpResult<'tcx, Result<FileAttributes, IoError>> {
) -> InterpResult<'tcx, FileAttributes> {
let file_attribute_normal = ecx.eval_windows_u32("c", "FILE_ATTRIBUTE_NORMAL");
let file_flag_backup_semantics = ecx.eval_windows_u32("c", "FILE_FLAG_BACKUP_SEMANTICS");
let file_flag_open_reparse_point =
Expand All @@ -128,7 +127,7 @@ impl FileAttributes {
} else if value & file_flag_open_reparse_point != 0 {
value &= !file_flag_open_reparse_point;
out |= FileAttributes::OPEN_REPARSE;
} else if value & file_attribute_normal {
} else if value & file_attribute_normal != 0 {
value &= !file_attribute_normal;
out |= FileAttributes::NORMAL;
}
Expand All @@ -140,7 +139,7 @@ impl FileAttributes {
if out == FileAttributes::ZERO {
out = FileAttributes::NORMAL;
}
interp_ok(Ok(out))
interp_ok(out)
}
}

Expand Down Expand Up @@ -189,7 +188,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
throw_unsup_format!("CreateFileW: Security attributes are not supported");
}

if attributes & FileAttributes::OPEN_REPARSE != 0 && creation_disposition == CreateAlways {
if attributes.contains(FileAttributes::OPEN_REPARSE) && creation_disposition == CreateAlways
{
throw_machine_stop!(TerminationInfo::Abort("Invalid CreateFileW argument combination: FILE_FLAG_OPEN_REPARSE_POINT with CREATE_ALWAYS".to_string()));
}

Expand Down
2 changes: 1 addition & 1 deletion src/shims/windows/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
}
Handle::File(fd_num) =>
if let Some(fd) = this.machine.fds.remove(fd_num) {
let err = fd.close(this.machine.communicate(), this)?;
let err = fd.close_ref(this.machine.communicate(), this)?;
if let Err(e) = err {
this.set_last_error(e)?;
this.eval_windows("c", "FALSE")
Expand Down

0 comments on commit 2e11722

Please sign in to comment.