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.
/// 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();
/// 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>,
// 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")?;
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),
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;
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);