From 003b257f87b94921594a46b4e0ad4dc22bb4cf4d Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Fri, 11 Oct 2019 08:20:32 -0500 Subject: [PATCH] Change error handling style for consistency --- src/helpers.rs | 6 +++--- src/shims/env.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/helpers.rs b/src/helpers.rs index b2a462ef906..c7b7853388c 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -296,12 +296,12 @@ fn visit_primitive(&mut self, _v: MPlaceTy<'tcx, Tag>) -> InterpResult<'tcx> fn eval_libc(&mut self, name: &str) -> InterpResult<'tcx, Scalar> { self.eval_context_mut() .eval_path_scalar(&["libc", name])? - .ok_or_else(|| err_unsup_format!("Path libc::{} cannot be resolved.", name).into()) - .and_then(|scalar| scalar.not_undef()) + .ok_or_else(|| err_unsup_format!("Path libc::{} cannot be resolved.", name))? + .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()) + self.eval_libc(name)?.to_i32() } } diff --git a/src/shims/env.rs b/src/shims/env.rs index 8c1645cde73..2ccbc0238e5 100644 --- a/src/shims/env.rs +++ b/src/shims/env.rs @@ -135,7 +135,7 @@ fn getcwd( let mut bytes = cwd.display().to_string().into_bytes(); // 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. + // 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); -- 2.44.0