1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-03 15:03:22 +02:00

flashrom_tester: Fix cargo check and clippy warnings

Change-Id: I50c5af61e06df1bb6956f347cb6806a7eca6ce0e
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/67472
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Evan Benn
2022-09-09 15:35:28 +10:00
committed by Angel Pons
parent 813c68ad9c
commit 1f65e9029b
8 changed files with 33 additions and 45 deletions

View File

@ -67,7 +67,7 @@ pub struct IOOpt<'a> {
pub region: Option<(&'a str, &'a str)>, // --image
}
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
pub struct FlashromCmd {
pub path: String,
pub fc: FlashChip,
@ -84,9 +84,9 @@ fn flashrom_extract_size(stdout: &str) -> Result<i64, FlashromError> {
.last()
.map(str::parse::<i64>)
{
None => return Err("Found no purely-numeric lines in flashrom output".into()),
None => Err("Found no purely-numeric lines in flashrom output".into()),
Some(Err(e)) => {
return Err(format!("Failed to parse flashrom size output as integer: {}", e).into())
Err(format!("Failed to parse flashrom size output as integer: {}", e).into())
}
Some(Ok(sz)) => Ok(sz),
}
@ -169,7 +169,7 @@ impl crate::Flashrom for FlashromCmd {
};
let (stdout, _) = self.dispatch(opts, "wp_list")?;
if stdout.len() == 0 {
if stdout.is_empty() {
return Err(
"wp_list isn't supported on platforms using the Linux kernel SPI driver wp_list"
.into(),
@ -208,7 +208,7 @@ impl crate::Flashrom for FlashromCmd {
let opts = FlashromOpt {
wp_opt: WPOpt {
range: range,
range,
enable: en,
disable: !en,
..Default::default()
@ -249,7 +249,7 @@ impl crate::Flashrom for FlashromCmd {
..Default::default()
};
let (stdout, _) = self.dispatch(opts, "read_region_into_file")?;
self.dispatch(opts, "read_region_into_file")?;
Ok(())
}
@ -405,11 +405,6 @@ pub fn dut_ctrl_toggle_wp(en: bool) -> Result<(Vec<u8>, Vec<u8>), FlashromError>
dut_ctrl(&args)
}
pub fn dut_ctrl_servo_type() -> Result<(Vec<u8>, Vec<u8>), FlashromError> {
let args = ["servo_type"];
dut_ctrl(&args)
}
fn dut_ctrl(args: &[&str]) -> Result<(Vec<u8>, Vec<u8>), FlashromError> {
let output = match Command::new("dut-control").args(args).output() {
Ok(x) => x,
@ -431,7 +426,7 @@ fn dut_ctrl(args: &[&str]) -> Result<(Vec<u8>, Vec<u8>), FlashromError> {
}
fn hex_range_string(s: i64, l: i64) -> String {
format!("{:#08X},{:#08X}", s, l).to_string()
format!("{:#08X},{:#08X}", s, l)
}
/// Get a flash vendor and name from the first matching line of flashrom output.

View File

@ -49,7 +49,7 @@ pub use libflashrom::{
FLASHROM_MSG_INFO, FLASHROM_MSG_SPEW, FLASHROM_MSG_WARN,
};
#[derive(Copy, Clone, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum FlashChip {
EC,
HOST,
@ -59,23 +59,21 @@ pub enum FlashChip {
impl FlashChip {
pub fn from(s: &str) -> Result<FlashChip, &str> {
let r = match s {
match s {
"ec" => Ok(FlashChip::EC),
"host" => Ok(FlashChip::HOST),
"servo" => Ok(FlashChip::SERVO),
"dediprog" => Ok(FlashChip::DEDIPROG),
_ => Err("cannot convert str to enum"),
};
return r;
}
}
pub fn to(fc: FlashChip) -> &'static str {
let r = match fc {
match fc {
FlashChip::EC => "ec",
FlashChip::HOST => "host",
FlashChip::SERVO => "ft2231_spi:type=servo-v2",
FlashChip::DEDIPROG => "dediprog",
};
return r;
}
}
/// Return the programmer string and optional programmer options
@ -97,7 +95,7 @@ impl FlashChip {
}
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct FlashromError {
msg: String,
}