]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #1100 - RalfJung:os_str, r=RalfJung
authorbors <bors@rust-lang.org>
Wed, 4 Dec 2019 09:44:29 +0000 (09:44 +0000)
committerbors <bors@rust-lang.org>
Wed, 4 Dec 2019 09:44:29 +0000 (09:44 +0000)
rename helper methods a bit

src/eval.rs
src/helpers.rs
src/shims/env.rs
src/shims/fs.rs

index 6f7f0ba329cec5092466be8c53e41d6e06ed9ea4..897d395674947eb083bc37bd75d392eb456c2900 100644 (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.
index 9f75c9b7fbe101cb3a8da79742c9cdc19f81c244..05a92164f27d82e7dfbc737ff0de9f0ef5d53009 100644 (file)
@@ -453,7 +453,7 @@ fn try_unwrap_io_result<T: From<i32>>(
 
     /// 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 @@ fn read_os_string_from_c_string<'a>(&'a self, scalar: Scalar<Tag>) -> InterpResu
     /// 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>,
index ae8dae0313f1bfc42c25560f20fac4e05178b6e9..8c431fd2016d553aa9683cab0d4af5b3bd0e8e52 100644 (file)
@@ -128,7 +128,7 @@ fn getcwd(
         // 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 @@ fn chdir(&mut self, path_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
 
         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),
index 9291f3a6e3b20d6c1204962b7b41cff49129c7ab..4d10be6264600abc48a1157e8bcf3fd5fa73394b 100644 (file)
@@ -96,7 +96,7 @@ fn open(
             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 @@ fn unlink(&mut self, path_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
 
         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);