diff options
| author | Evan Benn <evanbenn@chromium.org> | 2022-09-09 15:35:28 +1000 | 
|---|---|---|
| committer | Angel Pons <th3fanbus@gmail.com> | 2022-09-19 07:25:55 +0000 | 
| commit | 1f65e9029b8c9d0fbe6c60d8fee249c57fd3f3fa (patch) | |
| tree | 67a0721038563dc7b0d75da760387424217e2062 /util/flashrom_tester/src | |
| parent | 813c68ad9cf2bc61b9923b3eab429ed318359281 (diff) | |
| download | flashrom-1f65e9029b8c9d0fbe6c60d8fee249c57fd3f3fa.tar.gz flashrom-1f65e9029b8c9d0fbe6c60d8fee249c57fd3f3fa.tar.bz2 flashrom-1f65e9029b8c9d0fbe6c60d8fee249c57fd3f3fa.zip  | |
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>
Diffstat (limited to 'util/flashrom_tester/src')
| -rw-r--r-- | util/flashrom_tester/src/cros_sysinfo.rs | 1 | ||||
| -rw-r--r-- | util/flashrom_tester/src/logger.rs | 2 | ||||
| -rw-r--r-- | util/flashrom_tester/src/rand_util.rs | 4 | ||||
| -rw-r--r-- | util/flashrom_tester/src/tester.rs | 8 | ||||
| -rw-r--r-- | util/flashrom_tester/src/tests.rs | 22 | ||||
| -rw-r--r-- | util/flashrom_tester/src/utils.rs | 8 | 
6 files changed, 20 insertions, 25 deletions
diff --git a/util/flashrom_tester/src/cros_sysinfo.rs b/util/flashrom_tester/src/cros_sysinfo.rs index 7073eddf..e047f8e6 100644 --- a/util/flashrom_tester/src/cros_sysinfo.rs +++ b/util/flashrom_tester/src/cros_sysinfo.rs @@ -34,7 +34,6 @@  //  use std::ffi::OsStr; -use std::fmt::Debug;  use std::io::Result as IoResult;  use std::process::{Command, Stdio}; diff --git a/util/flashrom_tester/src/logger.rs b/util/flashrom_tester/src/logger.rs index e1c00f5d..12e54957 100644 --- a/util/flashrom_tester/src/logger.rs +++ b/util/flashrom_tester/src/logger.rs @@ -129,7 +129,7 @@ mod tests {              for record in records {                  if logger.enabled(record.metadata()) { -                    logger.log(&record); +                    logger.log(record);                  }              }          } diff --git a/util/flashrom_tester/src/rand_util.rs b/util/flashrom_tester/src/rand_util.rs index 51411d0d..1b0912be 100644 --- a/util/flashrom_tester/src/rand_util.rs +++ b/util/flashrom_tester/src/rand_util.rs @@ -42,9 +42,7 @@ use rand::prelude::*;  pub fn gen_rand_testdata(path: &str, size: usize) -> std::io::Result<()> {      let mut buf = BufWriter::new(File::create(path)?); -    let mut a: Vec<u8> = Vec::with_capacity(size); -    // Pad out array to be filled in by Rng::fill(). -    a.resize(size, 0b0); +    let mut a: Vec<u8> = vec![0; size];      thread_rng().fill(a.as_mut_slice());      buf.write_all(a.as_slice())?; diff --git a/util/flashrom_tester/src/tester.rs b/util/flashrom_tester/src/tester.rs index e701763a..f2c38465 100644 --- a/util/flashrom_tester/src/tester.rs +++ b/util/flashrom_tester/src/tester.rs @@ -69,8 +69,8 @@ impl<'a> TestEnv<'a> {      pub fn create(chip_type: FlashChip, cmd: &'a dyn Flashrom) -> Result<Self, FlashromError> {          let rom_sz = cmd.get_size()?;          let out = TestEnv { -            chip_type: chip_type, -            cmd: cmd, +            chip_type, +            cmd,              layout: utils::get_layout_sizes(rom_sz)?,              wp: WriteProtectState::from_hardware(cmd, chip_type)?,              original_flash_contents: "/tmp/flashrom_tester_golden.bin".into(), @@ -462,7 +462,7 @@ impl<T: TestCase + ?Sized> TestCase for &T {  }  #[allow(dead_code)] -#[derive(Copy, Clone, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Debug)]  pub enum TestConclusion {      Pass,      Fail, @@ -514,7 +514,7 @@ where      results  } -#[derive(Debug, PartialEq, Clone, Copy)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)]  pub enum OutputFormat {      Pretty,      Json, diff --git a/util/flashrom_tester/src/tests.rs b/util/flashrom_tester/src/tests.rs index 7d746b5d..1527a6e6 100644 --- a/util/flashrom_tester/src/tests.rs +++ b/util/flashrom_tester/src/tests.rs @@ -43,8 +43,8 @@ use std::fs::{self, File};  use std::io::{BufRead, Write};  use std::sync::atomic::AtomicBool; -const LAYOUT_FILE: &'static str = "/tmp/layout.file"; -const ELOG_FILE: &'static str = "/tmp/elog.file"; +const LAYOUT_FILE: &str = "/tmp/layout.file"; +const ELOG_FILE: &str = "/tmp/elog.file";  /// Iterate over tests, yielding only those tests with names matching filter_names.  /// @@ -79,6 +79,7 @@ fn filter_tests<'n, 't: 'n, T: TestCase>(  /// test_names is the case-insensitive names of tests to run; if None, then all  /// tests are run. Provided names that don't match any known test will be logged  /// as a warning. +#[allow(clippy::or_fun_call)] // This is used for to_string here and we don't care.  pub fn generic<'a, TN: Iterator<Item = &'a str>>(      cmd: &dyn Flashrom,      fc: FlashChip, @@ -132,11 +133,8 @@ pub fn generic<'a, TN: Iterator<Item = &'a str>>(      // Limit the tests to only those requested, unless none are requested      // in which case all tests are included. -    let mut filter_names: Option<HashSet<String>> = if let Some(names) = test_names { -        Some(names.map(|s| s.to_lowercase()).collect()) -    } else { -        None -    }; +    let mut filter_names: Option<HashSet<String>> = +        test_names.map(|names| names.map(|s| s.to_lowercase()).collect());      let tests = filter_tests(tests, &mut filter_names);      let chip_name = cmd @@ -153,15 +151,15 @@ pub fn generic<'a, TN: Iterator<Item = &'a str>>(          warn!("No test matches filter name \"{}\"", leftover);      } -    let os_rel = sys_info::os_release().unwrap_or("<Unknown OS>".to_string()); +    let os_release = sys_info::os_release().unwrap_or("<Unknown OS>".to_string());      let system_info = cros_sysinfo::system_info().unwrap_or("<Unknown System>".to_string());      let bios_info = cros_sysinfo::bios_info().unwrap_or("<Unknown BIOS>".to_string());      let meta_data = tester::ReportMetaData { -        chip_name: chip_name, -        os_release: os_rel, -        system_info: system_info, -        bios_info: bios_info, +        chip_name, +        os_release, +        system_info, +        bios_info,      };      tester::collate_all_test_runs(&results, meta_data, output_format);      Ok(()) diff --git a/util/flashrom_tester/src/utils.rs b/util/flashrom_tester/src/utils.rs index e8fbb531..4e8dd7cc 100644 --- a/util/flashrom_tester/src/utils.rs +++ b/util/flashrom_tester/src/utils.rs @@ -143,14 +143,14 @@ pub fn get_hardware_wp() -> std::result::Result<bool, String> {      match wp_s_val {          Ok(v) => {              if v == 1 { -                return Ok(true); +                Ok(true)              } else if v == 0 { -                return Ok(false); +                Ok(false)              } else { -                return Err("Unknown write protect value".into()); +                Err("Unknown write protect value".into())              }          } -        Err(_) => return Err("Cannot parse write protect value".into()), +        Err(_) => Err("Cannot parse write protect value".into()),      }  }  | 
