From 2e13878880fe7cf8cb5b1a8e5696914f3774ff62 Mon Sep 17 00:00:00 2001 From: bin liu Date: Wed, 21 Oct 2020 15:10:42 +0800 Subject: [PATCH] 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 --- src/agent/src/config.rs | 7 +++---- src/agent/src/rpc.rs | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/agent/src/config.rs b/src/agent/src/config.rs index 2c53bde203..1fd6345762 100644 --- a/src/agent/src/config.rs +++ b/src/agent/src/config.rs @@ -225,10 +225,9 @@ fn get_bool_value(param: &str) -> Result { // first try to parse as bool value v.parse::().or_else(|_err1| { // then try to parse as integer value - v.parse::().or_else(|_err2| Ok(0)).map(|v| match v { - 0 => false, - _ => true, - }) + v.parse::() + .or_else(|_err2| Ok(0)) + .map(|v| !matches!(v, 0)) }) } diff --git a/src/agent/src/rpc.rs b/src/agent/src/rpc.rs index 747a0433fc..03af6d8903 100644 --- a/src/agent/src/rpc.rs +++ b/src/agent/src/rpc.rs @@ -1203,7 +1203,7 @@ impl protocols::agent_ttrpc::AgentService for agentService { drop(sandbox); 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) => { info!(sl!(), "get_oom_event return {}", &container_id); let mut resp = OOMEvent::new(); @@ -1327,7 +1327,7 @@ fn read_stream(fd: RawFd, l: usize) -> Result> { } Err(e) => match e { 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!("read error")),