Skip to content

Commit 813d76d

Browse files
committed
follow-up to reviews
1 parent 160ebaa commit 813d76d

File tree

2 files changed

+7
-33
lines changed

2 files changed

+7
-33
lines changed

src/helpers.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -588,21 +588,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
588588
Ok((true, string_length))
589589
}
590590

591-
/// Dispatches to appropriate implementations for allocating & writing OsString in Memory,
592-
/// depending on the interpretation target.
593-
fn alloc_os_str_as_target_str(
594-
&mut self,
595-
os_str: &OsStr,
596-
memkind: MemoryKind<MiriMemoryKind>,
597-
) -> InterpResult<'tcx, Pointer<Tag>> {
598-
let target_os = self.eval_context_ref().tcx.sess.target.target.target_os.as_str();
599-
match target_os {
600-
"linux" | "macos" => Ok(self.alloc_os_str_as_c_str(os_str, memkind)),
601-
"windows" => Ok(self.alloc_os_str_as_wide_str(os_str, memkind)),
602-
unsupported => throw_unsup_format!("OsString support for target OS `{}` not yet available", unsupported),
603-
}
604-
}
605-
606591
/// Allocate enough memory to store the given `OsStr` as a null-terminated sequence of bytes.
607592
fn alloc_os_str_as_c_str(
608593
&mut self,

src/shims/env.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ pub struct EnvVars<'tcx> {
2323
impl<'tcx> EnvVars<'tcx> {
2424
pub(crate) fn init<'mir>(
2525
ecx: &mut InterpCx<'mir, 'tcx, Evaluator<'tcx>>,
26-
mut excluded_env_vars: Vec<String>,
26+
excluded_env_vars: Vec<String>,
2727
) -> InterpResult<'tcx> {
28-
if ecx.tcx.sess.target.target.target_os == "windows" {
29-
// Exclude `TERM` var to avoid terminfo trying to open the termcap file.
30-
excluded_env_vars.push("TERM".to_owned());
31-
}
3228
if ecx.machine.communicate {
29+
let target_os = ecx.tcx.sess.target.target.target_os.as_str();
3330
for (name, value) in env::vars() {
3431
if !excluded_env_vars.contains(&name) {
35-
let var_ptr =
36-
alloc_env_var_as_target_str(name.as_ref(), value.as_ref(), ecx)?;
32+
let var_ptr = match target_os {
33+
"linux" | "macos" => alloc_env_var_as_c_str(name.as_ref(), value.as_ref(), ecx)?,
34+
"windows" => alloc_env_var_as_wide_str(name.as_ref(), value.as_ref(), ecx)?,
35+
unsupported => throw_unsup_format!("OsString support for target OS `{}` not yet available", unsupported),
36+
};
3737
ecx.machine.env_vars.map.insert(OsString::from(name), var_ptr);
3838
}
3939
}
@@ -42,17 +42,6 @@ impl<'tcx> EnvVars<'tcx> {
4242
}
4343
}
4444

45-
fn alloc_env_var_as_target_str<'mir, 'tcx>(
46-
name: &OsStr,
47-
value: &OsStr,
48-
ecx: &mut InterpCx<'mir, 'tcx, Evaluator<'tcx>>,
49-
) -> InterpResult<'tcx, Pointer<Tag>> {
50-
let mut name_osstring = name.to_os_string();
51-
name_osstring.push("=");
52-
name_osstring.push(value);
53-
Ok(ecx.alloc_os_str_as_target_str(name_osstring.as_os_str(), MiriMemoryKind::Machine.into())?)
54-
}
55-
5645
fn alloc_env_var_as_c_str<'mir, 'tcx>(
5746
name: &OsStr,
5847
value: &OsStr,

0 commit comments

Comments
 (0)