Make debug function never return error

This commit is contained in:
Jeremy Soller
2017-10-29 15:31:35 -06:00
parent ffad0f2ace
commit 1f99d038c4
2 changed files with 10 additions and 18 deletions

View File

@@ -26,14 +26,7 @@ pub fn resource() -> Result<Vec<u8>> {
let _ = writeln!(string, "{}: {}", id, name);
if let Some((a, b, c, d, e, f)) = row.2 {
match syscall::debug::format_call(a, b, c, d, e, f) {
Ok(data) => {
let _ = writeln!(string, " {}", data);
},
Err(err) => {
let _ = writeln!(string, " error: {}", err);
}
};
let _ = writeln!(string, " {}", syscall::debug::format_call(a, b, c, d, e, f));
}
}
}

View File

@@ -3,7 +3,6 @@ use core::ops::Range;
use alloc::{String, Vec};
use super::data::{Stat, TimeSpec};
use super::error::Result;
use super::flag::*;
use super::number::*;
use super::validate::*;
@@ -58,8 +57,8 @@ impl<'a> ::core::fmt::Debug for ByteStr<'a> {
}
pub fn format_call(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -> Result<String> {
Ok(match a {
pub fn format_call(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -> String {
match a {
SYS_OPEN => format!(
"open({:?}, {:#X})",
validate_slice(b as *const u8, c).map(ByteStr),
@@ -199,12 +198,12 @@ pub fn format_call(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -
validate_slice(
d as *const [usize; 2],
e
)?
.iter()
.map(|a|
validate_slice(a[0] as *const u8, a[1]).ok()
.and_then(|s| ::core::str::from_utf8(s).ok())
).collect::<Vec<Option<&str>>>()
).map(|slice| {
slice.iter().map(|a|
validate_slice(a[0] as *const u8, a[1]).ok()
.and_then(|s| ::core::str::from_utf8(s).ok())
).collect::<Vec<Option<&str>>>()
})
),
SYS_EXIT => format!(
"exit({})",
@@ -317,5 +316,5 @@ pub fn format_call(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -
e,
f
)
})
}
}