Fix new clippy warnings from Rust 1.45.0

Fix a few instances of and_then(Ok(...)) in syslog:
https://rust-lang.github.io/rust-clippy/master/index.html#bind_instead_of_map

And an unused (overwritten) variable assignment in the argument tests.

BUG=None
TEST=docker/wrapped_smoke_test.sh

Change-Id: Id59b1749fd7eba1fe7dfeb7938ecbbc9d0f9aa6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2303275
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Daniel Verkamp 2020-07-16 11:26:32 -07:00 committed by Commit Bot
parent eef1c93fdc
commit f4f8f86873
2 changed files with 12 additions and 18 deletions

View file

@ -505,23 +505,17 @@ mod tests {
"foo" => assert!(value.is_none()), "foo" => assert!(value.is_none()),
"bar" => assert_eq!(value.unwrap(), "stuff"), "bar" => assert_eq!(value.unwrap(), "stuff"),
"gpu" => match value { "gpu" => match value {
Some(v) => { Some(v) => match v {
match v { "2D" | "3D" => {
"2D" => { gpu_value = Some(v.to_string());
gpu_value = Some("2D".to_string());
}
"3D" => {
gpu_value = Some("3D".to_string());
}
_ => {
return Err(Error::InvalidValue {
value: v.to_string(),
expected: String::from("2D or 3D"),
})
}
} }
gpu_value = Some(v.to_string()); _ => {
} return Err(Error::InvalidValue {
value: v.to_string(),
expected: String::from("2D or 3D"),
})
}
},
None => { None => {
gpu_value = None; gpu_value = None;
} }

View file

@ -439,7 +439,7 @@ pub fn log(pri: Priority, fac: Facility, file_line: Option<(&str, u32)>, args: f
} }
}) })
.and_then(|()| write!(&mut buf_cursor, "{}", args)) .and_then(|()| write!(&mut buf_cursor, "{}", args))
.and_then(|()| Ok(buf_cursor.position() as usize)) .map(|()| buf_cursor.position() as usize)
}; };
if let Ok(len) = &res { if let Ok(len) = &res {
@ -455,7 +455,7 @@ pub fn log(pri: Priority, fac: Facility, file_line: Option<(&str, u32)>, args: f
Ok(()) Ok(())
} }
.and_then(|()| writeln!(&mut buf_cursor, "{}", args)) .and_then(|()| writeln!(&mut buf_cursor, "{}", args))
.and_then(|()| Ok(buf_cursor.position() as usize)) .map(|()| buf_cursor.position() as usize)
}; };
if let Ok(len) = &res { if let Ok(len) = &res {
if let Some(file) = &mut state.file { if let Some(file) = &mut state.file {