serial: fix clippy warnings

Resolve couple of minor clippy warnings:
 - unneeded return statement in last expression of the function
 - redundant closure

BUG=None
TEST=./bin/clippy
TEST=cargo build

Change-Id: I602e56289315cb88779c0029d400b24a8180b899
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1646738
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jakub Staroń <jstaron@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
This commit is contained in:
Jakub Staron 2019-06-05 14:50:46 -07:00 committed by Commit Bot
parent 4197d3a3a1
commit d879219ac0

View file

@ -110,11 +110,11 @@ impl FromStr for SerialType {
type Err = Error;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
match s {
"file" | "File" => return Ok(SerialType::File),
"stdout" | "Stdout" => return Ok(SerialType::Stdout),
"sink" | "Sink" => return Ok(SerialType::Sink),
"syslog" | "Syslog" => return Ok(SerialType::Syslog),
"unix" | "UnixSocket" => return Ok(SerialType::UnixSocket),
"file" | "File" => Ok(SerialType::File),
"stdout" | "Stdout" => Ok(SerialType::Stdout),
"sink" | "Sink" => Ok(SerialType::Sink),
"syslog" | "Syslog" => Ok(SerialType::Syslog),
"unix" | "UnixSocket" => Ok(SerialType::UnixSocket),
_ => Err(Error::InvalidSerialType(s.to_string())),
}
}
@ -154,7 +154,7 @@ impl SerialParameters {
None => Err(Error::PathRequired),
Some(path) => Ok(Serial::new_out(
evt_fd.try_clone().map_err(Error::CloneEventFd)?,
Box::new(File::create(path.as_path()).map_err(|e| Error::FileError(e))?),
Box::new(File::create(path.as_path()).map_err(Error::FileError)?),
)),
},
SerialType::UnixSocket => Err(Error::Unimplemented(SerialType::UnixSocket)),