firmware: remove some unnecessary unwraps.

This commit is contained in:
whitequark 2018-05-15 15:01:30 +00:00
parent e5796e26e1
commit 9f5b76253c
2 changed files with 4 additions and 5 deletions

View File

@ -1,5 +1,6 @@
use alloc::btree_map::BTreeMap;
use io::Error as IoError;
use moninj_proto::*;
use sched::{Io, TcpListener, TcpStream, Error as SchedError};
use board_misoc::{clock, csr};
@ -184,7 +185,7 @@ fn connection_worker(io: &Io, mut stream: &mut TcpStream) -> Result<(), Error<Sc
if clock::get_ms() > next_check {
for (&(channel, probe), previous) in watch_list.iter_mut() {
let current = read_probe(channel, probe);
if previous.is_none() || (previous.unwrap() != current) {
if previous.is_none() || previous.unwrap() != current {
let message = DeviceMessage::MonitorStatus {
channel: channel,
probe: probe,
@ -200,7 +201,7 @@ fn connection_worker(io: &Io, mut stream: &mut TcpStream) -> Result<(), Error<Sc
next_check = clock::get_ms() + 200;
}
io.relinquish().unwrap();
io.relinquish().map_err(|err| Error::Io(IoError::Other(err)))?;
}
}

View File

@ -1,8 +1,6 @@
use core::mem;
use alloc::{Vec, String, BTreeMap};
use io::Write;
const ALIGNMENT: usize = 64;
#[derive(Debug)]
@ -37,7 +35,7 @@ impl Manager {
}
pub fn record_append(&mut self, data: &[u8]) {
self.recording_trace.write_all(data).unwrap();
self.recording_trace.extend_from_slice(data)
}
pub fn record_stop(&mut self, duration: u64) {