agent: clear match_like_matches_macro/vec_resize_to_zero warnings

This commit fix these warnings for Rust v1.47.0:

- match_like_matches_macro
- vec_resize_to_zero

Signed-off-by: bin liu <bin@hyper.sh>
This commit is contained in:
bin liu 2020-10-21 15:10:42 +08:00
parent 227edfdc9f
commit 2e13878880
2 changed files with 5 additions and 6 deletions

View File

@ -225,10 +225,9 @@ fn get_bool_value(param: &str) -> Result<bool> {
// first try to parse as bool value // first try to parse as bool value
v.parse::<bool>().or_else(|_err1| { v.parse::<bool>().or_else(|_err1| {
// then try to parse as integer value // then try to parse as integer value
v.parse::<u64>().or_else(|_err2| Ok(0)).map(|v| match v { v.parse::<u64>()
0 => false, .or_else(|_err2| Ok(0))
_ => true, .map(|v| !matches!(v, 0))
})
}) })
} }

View File

@ -1203,7 +1203,7 @@ impl protocols::agent_ttrpc::AgentService for agentService {
drop(sandbox); drop(sandbox);
match event_rx.recv() { match event_rx.recv() {
Err(err) => return Err(ttrpc_error(ttrpc::Code::INTERNAL, err.to_string())), Err(err) => Err(ttrpc_error(ttrpc::Code::INTERNAL, err.to_string())),
Ok(container_id) => { Ok(container_id) => {
info!(sl!(), "get_oom_event return {}", &container_id); info!(sl!(), "get_oom_event return {}", &container_id);
let mut resp = OOMEvent::new(); let mut resp = OOMEvent::new();
@ -1327,7 +1327,7 @@ fn read_stream(fd: RawFd, l: usize) -> Result<Vec<u8>> {
} }
Err(e) => match e { Err(e) => match e {
nix::Error::Sys(errno) => match errno { nix::Error::Sys(errno) => match errno {
Errno::EAGAIN => v.resize(0, 0), Errno::EAGAIN => v.clear(),
_ => return Err(anyhow!(nix::Error::Sys(errno))), _ => return Err(anyhow!(nix::Error::Sys(errno))),
}, },
_ => return Err(anyhow!("read error")), _ => return Err(anyhow!("read error")),