Auto merge of #1100 - RalfJung:os_str, r=RalfJung

rename helper methods a bit
This commit is contained in:
bors 2019-12-04 09:44:29 +00:00
commit 878bb4d78f
4 changed files with 7 additions and 7 deletions

View File

@ -84,7 +84,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
let size = arg.len() as u64 + 1;
let arg_type = tcx.mk_array(tcx.types.u8, size);
let arg_place = ecx.allocate(ecx.layout_of(arg_type)?, MiriMemoryKind::Env.into());
ecx.write_os_str_to_c_string(OsStr::new(arg), arg_place.ptr, size)?;
ecx.write_os_str_to_c_str(OsStr::new(arg), arg_place.ptr, size)?;
argvs.push(arg_place.ptr);
}
// Make an array with all these pointers, in the Miri memory.

View File

@ -453,7 +453,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
/// Helper function to read an OsString from a null-terminated sequence of bytes, which is what
/// the Unix APIs usually handle.
fn read_os_string_from_c_string<'a>(&'a self, scalar: Scalar<Tag>) -> InterpResult<'tcx, &'a OsStr>
fn read_os_str_from_c_str<'a>(&'a self, scalar: Scalar<Tag>) -> InterpResult<'tcx, &'a OsStr>
where 'tcx: 'a, 'mir: 'a
{
let this = self.eval_context_ref();
@ -465,7 +465,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
/// the Unix APIs usually handle. This function returns `Ok(false)` without trying to write if
/// `size` is not large enough to fit the contents of `os_string` plus a null terminator. It
/// returns `Ok(true)` if the writing process was successful.
fn write_os_str_to_c_string(
fn write_os_str_to_c_str(
&mut self,
os_str: &OsStr,
scalar: Scalar<Tag>,

View File

@ -128,7 +128,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
// If we cannot get the current directory, we return null
match env::current_dir() {
Ok(cwd) => {
if this.write_os_str_to_c_string(&OsString::from(cwd), buf, size)? {
if this.write_os_str_to_c_str(&OsString::from(cwd), buf, size)? {
return Ok(buf);
}
let erange = this.eval_libc("ERANGE")?;
@ -144,7 +144,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
this.check_no_isolation("chdir")?;
let path = this.read_os_string_from_c_string(this.read_scalar(path_op)?.not_undef()?)?;
let path = this.read_os_str_from_c_str(this.read_scalar(path_op)?.not_undef()?)?;
match env::set_current_dir(path) {
Ok(()) => Ok(0),

View File

@ -96,7 +96,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
throw_unsup_format!("unsupported flags {:#x}", flag & !mirror);
}
let path = this.read_os_string_from_c_string(this.read_scalar(path_op)?.not_undef()?)?;
let path = this.read_os_str_from_c_str(this.read_scalar(path_op)?.not_undef()?)?;
let fd = options.open(path).map(|file| {
let mut fh = &mut this.machine.file_handler;
@ -250,7 +250,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
this.check_no_isolation("unlink")?;
let path = this.read_os_string_from_c_string(this.read_scalar(path_op)?.not_undef()?)?;
let path = this.read_os_str_from_c_str(this.read_scalar(path_op)?.not_undef()?)?;
let result = remove_file(path).map(|_| 0);