Skip to content

Commit

Permalink
tool: Fix clippy warnings
Browse files Browse the repository at this point in the history
Fix:

- clippy::unnecessary_cast
- clippy::needless_borrow

Allow:

- clippy::uninlined_format_args
- clippy::get_first

Signed-off-by: Tim Crawford <[email protected]>
  • Loading branch information
crawfxrd committed Oct 5, 2023
1 parent 0dbd2a1 commit 253ba55
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tool/src/access/lpc/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions tool/src/access/lpc/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl AccessLpcSim {

fn transaction(&mut self, kind: u8, addr: u16, value: u8) -> io::Result<u8> {
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,
Expand Down Expand Up @@ -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();
Expand Down
9 changes: 6 additions & 3 deletions tool/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: MIT

#![allow(clippy::uninlined_format_args)]

use clap::{Arg, App, AppSettings, SubCommand};
use ectool::{
Access,
Expand Down Expand Up @@ -225,6 +227,7 @@ unsafe fn matrix(ec: &mut Ec<Box<dyn Access>>) -> 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;
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions tool/src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 253ba55

Please sign in to comment.