From 67ea4546472edace0ae1d8fc97ae85bf5953e8a5 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Fri, 11 Oct 2019 04:17:43 -0500 Subject: [PATCH] Correct style of comments --- src/helpers.rs | 2 ++ src/shims/env.rs | 6 +++--- tests/run-pass/current_dir.rs | 10 +++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/helpers.rs b/src/helpers.rs index 39c7af94e0ae..b2a462ef9067 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -291,6 +291,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx } } } + /// Helper function to get a `libc` constant as a `Scalar`. fn eval_libc(&mut self, name: &str) -> InterpResult<'tcx, Scalar> { self.eval_context_mut() @@ -298,6 +299,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx .ok_or_else(|| err_unsup_format!("Path libc::{} cannot be resolved.", name).into()) .and_then(|scalar| scalar.not_undef()) } + /// Helper function to get a `libc` constant as an `i32`. fn eval_libc_i32(&mut self, name: &str) -> InterpResult<'tcx, i32> { self.eval_libc(name).and_then(|scalar| scalar.to_i32()) diff --git a/src/shims/env.rs b/src/shims/env.rs index b39bde4dedc6..6f32783d7a76 100644 --- a/src/shims/env.rs +++ b/src/shims/env.rs @@ -133,9 +133,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx Ok(cwd) => { // It is not clear what happens with non-utf8 paths here let mut bytes = cwd.display().to_string().into_bytes(); - // If `size` is smaller or equal than the `bytes.len()`, writing `bytes` using the - // `buf` pointer would cause an overflow, the desired behavior in this case is to - // return null. + // If `size` is smaller or equal than the `bytes.len()`, writing `bytes` plus the + // required null terminator to memory using the `buf` pointer would cause an + // overflow, the desired behavior in this case is to return null. if (bytes.len() as u64) < size { // We add a `/0` terminator bytes.push(0); diff --git a/tests/run-pass/current_dir.rs b/tests/run-pass/current_dir.rs index 48045187ab15..5e896659c85e 100644 --- a/tests/run-pass/current_dir.rs +++ b/tests/run-pass/current_dir.rs @@ -4,14 +4,14 @@ use std::env; use std::path::Path; fn main() { - // test that `getcwd` is available + // Test that `getcwd` is available let cwd = env::current_dir().unwrap(); - // test that changing dir to `..` actually sets the current directory to the parent of `cwd`. - // the only exception here is if `cwd` is the root directory, then changing directory must + // Test that changing dir to `..` actually sets the current directory to the parent of `cwd`. + // The only exception here is if `cwd` is the root directory, then changing directory must // keep the current directory equal to `cwd`. let parent = cwd.parent().unwrap_or(&cwd); - // test that `chdir` is available + // Test that `chdir` is available assert!(env::set_current_dir(&Path::new("..")).is_ok()); - // test that `..` goes to the parent directory + // Test that `..` goes to the parent directory assert_eq!(env::current_dir().unwrap(), parent); }