Skip to content

Commit 878bb4d

Browse files
committed
Auto merge of #1100 - RalfJung:os_str, r=RalfJung
rename helper methods a bit
2 parents 53fcf47 + 94732aa commit 878bb4d

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
8484
let size = arg.len() as u64 + 1;
8585
let arg_type = tcx.mk_array(tcx.types.u8, size);
8686
let arg_place = ecx.allocate(ecx.layout_of(arg_type)?, MiriMemoryKind::Env.into());
87-
ecx.write_os_str_to_c_string(OsStr::new(arg), arg_place.ptr, size)?;
87+
ecx.write_os_str_to_c_str(OsStr::new(arg), arg_place.ptr, size)?;
8888
argvs.push(arg_place.ptr);
8989
}
9090
// Make an array with all these pointers, in the Miri memory.

src/helpers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
453453

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

src/shims/env.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
128128
// If we cannot get the current directory, we return null
129129
match env::current_dir() {
130130
Ok(cwd) => {
131-
if this.write_os_str_to_c_string(&OsString::from(cwd), buf, size)? {
131+
if this.write_os_str_to_c_str(&OsString::from(cwd), buf, size)? {
132132
return Ok(buf);
133133
}
134134
let erange = this.eval_libc("ERANGE")?;
@@ -144,7 +144,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
144144

145145
this.check_no_isolation("chdir")?;
146146

147-
let path = this.read_os_string_from_c_string(this.read_scalar(path_op)?.not_undef()?)?;
147+
let path = this.read_os_str_from_c_str(this.read_scalar(path_op)?.not_undef()?)?;
148148

149149
match env::set_current_dir(path) {
150150
Ok(()) => Ok(0),

src/shims/fs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
9696
throw_unsup_format!("unsupported flags {:#x}", flag & !mirror);
9797
}
9898

99-
let path = this.read_os_string_from_c_string(this.read_scalar(path_op)?.not_undef()?)?;
99+
let path = this.read_os_str_from_c_str(this.read_scalar(path_op)?.not_undef()?)?;
100100

101101
let fd = options.open(path).map(|file| {
102102
let mut fh = &mut this.machine.file_handler;
@@ -250,7 +250,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
250250

251251
this.check_no_isolation("unlink")?;
252252

253-
let path = this.read_os_string_from_c_string(this.read_scalar(path_op)?.not_undef()?)?;
253+
let path = this.read_os_str_from_c_str(this.read_scalar(path_op)?.not_undef()?)?;
254254

255255
let result = remove_file(path).map(|_| 0);
256256

0 commit comments

Comments
 (0)