From 253ba55496d0c854df4eed6209e8e844c17d3b05 Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Thu, 5 Oct 2023 10:10:44 -0600 Subject: [PATCH] tool: Fix clippy warnings Fix: - clippy::unnecessary_cast - clippy::needless_borrow Allow: - clippy::uninlined_format_args - clippy::get_first Signed-off-by: Tim Crawford --- tool/src/access/lpc/linux.rs | 2 +- tool/src/access/lpc/sim.rs | 4 ++-- tool/src/main.rs | 9 ++++++--- tool/src/spi.rs | 1 + 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tool/src/access/lpc/linux.rs b/tool/src/access/lpc/linux.rs index ce0130231..f26a24806 100644 --- a/tool/src/access/lpc/linux.rs +++ b/tool/src/access/lpc/linux.rs @@ -158,7 +158,7 @@ impl Access for AccessLpcLinux { } // Write command byte, which starts command - self.write_cmd(SMFI_CMD_CMD, cmd as u8)?; + self.write_cmd(SMFI_CMD_CMD, cmd)?; // Wait for command to finish with timeout self.timeout.reset(); diff --git a/tool/src/access/lpc/sim.rs b/tool/src/access/lpc/sim.rs index 4998ba4c6..46f3b243c 100644 --- a/tool/src/access/lpc/sim.rs +++ b/tool/src/access/lpc/sim.rs @@ -35,7 +35,7 @@ impl AccessLpcSim { fn transaction(&mut self, kind: u8, addr: u16, value: u8) -> io::Result { let addr = addr.to_le_bytes(); - let request = [kind as u8, addr[0], addr[1], value]; + let request = [kind, addr[0], addr[1], value]; if self.socket.send(&request)? != request.len() { return Err(io::Error::new( io::ErrorKind::UnexpectedEof, @@ -99,7 +99,7 @@ impl Access for AccessLpcSim { } // Write command byte, which starts command - self.write_cmd(SMFI_CMD_CMD, cmd as u8)?; + self.write_cmd(SMFI_CMD_CMD, cmd)?; // Wait for command to finish with timeout self.timeout.reset(); diff --git a/tool/src/main.rs b/tool/src/main.rs index 91ceb7794..8bb3f4227 100644 --- a/tool/src/main.rs +++ b/tool/src/main.rs @@ -1,5 +1,7 @@ // SPDX-License-Identifier: MIT +#![allow(clippy::uninlined_format_args)] + use clap::{Arg, App, AppSettings, SubCommand}; use ectool::{ Access, @@ -225,6 +227,7 @@ unsafe fn matrix(ec: &mut Ec>) -> Result<(), Error> { let mut data = vec![0; data_size]; ec.matrix_get(&mut data)?; + #[allow(clippy::get_first)] let rows = *data.get(0).unwrap_or(&0); let cols = *data.get(1).unwrap_or(&0); let mut byte = 2; @@ -305,7 +308,7 @@ fn main() { .setting(AppSettings::SubcommandRequired) .arg(Arg::with_name("access") .long("access") - .possible_values(&["lpc-linux", "lpc-sim", "hid"]) + .possible_values(["lpc-linux", "lpc-sim", "hid"]) .default_value("lpc-linux") ) .subcommand(SubCommand::with_name("console")) @@ -386,13 +389,13 @@ fn main() { ) .subcommand(SubCommand::with_name("set_no_input") .arg(Arg::with_name("value") - .possible_values(&["true", "false"]) + .possible_values(["true", "false"]) .required(true) ) ) .subcommand(SubCommand::with_name("security") .arg(Arg::with_name("state") - .possible_values(&["lock", "unlock"]) + .possible_values(["lock", "unlock"]) ) ) .get_matches(); diff --git a/tool/src/spi.rs b/tool/src/spi.rs index 7ce669429..b3d8cf343 100644 --- a/tool/src/spi.rs +++ b/tool/src/spi.rs @@ -154,6 +154,7 @@ impl<'a, S: Spi, T: Timeout> SpiRom<'a, S, T> { //TODO: automatically detect write command match self.spi.target() { SpiTarget::Main => for (i, word) in data.chunks(2).enumerate() { + #[allow(clippy::get_first)] let low = *word.get(0).unwrap_or(&0xFF); let high = *word.get(1).unwrap_or(&0xFF);